Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp591797rdb; Tue, 23 Jan 2024 08:38:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEsCOwrJC3AieTL7B2i42Ukl235TUBXzR8QzRJ4tQnIjx+I+QZQnLCvgAg1rzUXPsCcfY/ X-Received: by 2002:a05:6358:917:b0:176:5180:81bc with SMTP id r23-20020a056358091700b00176518081bcmr3359481rwi.52.1706027900474; Tue, 23 Jan 2024 08:38:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706027900; cv=pass; d=google.com; s=arc-20160816; b=jMKe8Qp3fGGzyFVZRDn8lOkl5HulmoVdrUK85tH737hTtP3PRSjxO6ZKrO6hvTACCE ts1qfRNpVOzFTbZ8fHObBc61XJ/Na5xjNOknT41+BEXR+zTCpmS3QQMCGInLPLTpJCt7 XwnT8SgQnUfjkX3gd30J6kb4zD7flzjDL6Dziaf8XwUIwvAfh19y2/eaJVMo1eUHFH45 +xyYkTAIDteK2+hZCLcwp6OfOlWrp2RHBUQXbfDvTC61jMtEkpShUElhbFO70yXUQVm5 26uQ4q8DsR71MniVprNJt1vXIcvoMOU/PQcfhgSWIVPdR3aVeCDsds1gNW00BL9wBjW5 6kHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bgvmGI1WvRaGQtO6cF0xR2F5H/hltWKL+Ey04aoYvK0=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=BOoQLAw5DKqRGl8P5Ff7juNvaT8oWmK2gxCc82qHcUupV/AC5apZeu1HMxTjRFH4gv uPenlTnYp/TJMy2hbUNWX4RWMGED5HbHg4Y/33NOozd7ShSi8QJ+G2rXAd8hjb8qc/sx aiPwClDsBoGCWJ/y0NS4rlfbNs6vKkXNZrgiw9KG2/kqniJQc8hx47W+/rV84ObuImzG DyhZXHeJIoxk4vDEgWqpV+chqtVYppoPTuYiFRtxrzCL/ENQuAejHfPQRdd3ayIK/Dn5 XwniWKEE/HjQCafpBD9Zxe7g+Nctk9JxPEUX1NkjqHqa1Z1P5x5159w1LtAQM9N5Y7zx xlNg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V+y8O77G; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r16-20020a0ccc10000000b0068687624743si5764118qvk.523.2024.01.23.08.38.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:38:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V+y8O77G; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A9A51C237A7 for ; Tue, 23 Jan 2024 16:38:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95F528005A; Tue, 23 Jan 2024 16:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="V+y8O77G" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 155FF7FBAC; Tue, 23 Jan 2024 16:37:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027825; cv=none; b=pAJQ0e0SpziMVTNNlnQfB+/2qNEBvSUgj5c8Q7EVCugN7rkaeHhu7O+9befIKNqsQpLPvuOg6HkAGYhqhsxByS+ZSzD7wkqcfkwxNTKI4POmXXojcx2lqxUmlBRrMiVWQIGEoZ9WIavahaHit0/7u2XTnW8RfN8gnQ4BFtq5rqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027825; c=relaxed/simple; bh=6EbfTxVZTsZcDz6soZJ7jpZfyhuxH4m975EW/o+lIBk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FCAQ9U1gKoaMvnvuyn54zF5+SRptV3b2gXg9vNasbuVejI9n0dO5POD2BWtUwOS9E2drKYh5oz0aaXMfXOgEu2INTHbBYrMlbnNnC12Xa9r2E1CCVoroFmnvrbeJTMDfsQeOFP/ET6qELkUpQqOEoSX/nkJogM4nTJNylP51P44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=V+y8O77G; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGawJN077092; Tue, 23 Jan 2024 10:36:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027818; bh=bgvmGI1WvRaGQtO6cF0xR2F5H/hltWKL+Ey04aoYvK0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=V+y8O77GeCqoZo7qKU7dU2fAtoC1NawLPUp+WHvRsv8TSwZCSBMjMb9itjMmNNRwF SUdXSVUF8VfDitIHB67sFP3vjemrTIwp2KTihVvXhoLnQAk6dWOxgRgVM3HFrRCNQa 65gzY1QNJ2rZQhFvTacPG7qIiVreUWS44UV/Ody8= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGaw8v119722 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:36:58 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 23 Jan 2024 10:36:57 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 23 Jan 2024 10:36:57 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40NGarrx123403; Tue, 23 Jan 2024 10:36:57 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?UTF-8?q?Pali=20Roh=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 11/21] power: supply: rt5033: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:43 -0600 Message-ID: <20240123163653.384385-12-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123163653.384385-1-afd@ti.com> References: <20240123163653.384385-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis --- drivers/power/supply/rt5033_battery.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c index d90b96df8e73d..32eafe2c00af5 100644 --- a/drivers/power/supply/rt5033_battery.c +++ b/drivers/power/supply/rt5033_battery.c @@ -159,12 +159,12 @@ static int rt5033_battery_probe(struct i2c_client *client) return -EINVAL; } - i2c_set_clientdata(client, battery); psy_cfg.of_node = client->dev.of_node; psy_cfg.drv_data = battery; - battery->psy = power_supply_register(&client->dev, - &rt5033_battery_desc, &psy_cfg); + battery->psy = devm_power_supply_register(&client->dev, + &rt5033_battery_desc, + &psy_cfg); if (IS_ERR(battery->psy)) return dev_err_probe(&client->dev, PTR_ERR(battery->psy), "Failed to register power supply\n"); @@ -172,13 +172,6 @@ static int rt5033_battery_probe(struct i2c_client *client) return 0; } -static void rt5033_battery_remove(struct i2c_client *client) -{ - struct rt5033_battery *battery = i2c_get_clientdata(client); - - power_supply_unregister(battery->psy); -} - static const struct i2c_device_id rt5033_battery_id[] = { { "rt5033-battery", }, { } @@ -197,7 +190,6 @@ static struct i2c_driver rt5033_battery_driver = { .of_match_table = rt5033_battery_of_match, }, .probe = rt5033_battery_probe, - .remove = rt5033_battery_remove, .id_table = rt5033_battery_id, }; module_i2c_driver(rt5033_battery_driver); -- 2.39.2