Message ID | 20240123163653.384385-16-afd@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-35669-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp460162dyi; Tue, 23 Jan 2024 08:42:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGU4envWwyCeHl6C3aHQEk+Pvlz+6NZBBx/aWV2amHZDzvbXArteWUsCNB9/vbwNVt3Mt0x X-Received: by 2002:ae9:e604:0:b0:783:a973:f9a1 with SMTP id z4-20020ae9e604000000b00783a973f9a1mr1416305qkf.104.1706028171236; Tue, 23 Jan 2024 08:42:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706028171; cv=pass; d=google.com; s=arc-20160816; b=rXvUOz9zppBg0KbaIgzwz26DEpyh3oQvIXI110pVRh0kRb5i8KpjuHeCg6InNLUzeS k6k+ff1muw7kNUHY/ug4+lP8UGuFnDI/ZIriDt6FI635f6WYiFSZyLb6AIxBqg2DmfVD oE8wX1mSudWc4iS5LJJcyftH58XMDrwOU92JXUL8pHDKVU/QIlChrTuQIYLaT/0qHyeh CAA7sQDcqGjaVGSzaTvz3JvKfKsWeNg6zb3ZsVsqFnsqKRkjDz3+P6C2WhvDhHLkaECk n1hRiiNkI79pvBumEraMq0jLQfXbSXyRkDi6tjpkqIwrMws51aShMn/6ST66dCX6FtQL 1VeQ== 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=NynlMJZVVWmFK6HEqJQ06332dhB5iMXyjOa26cOux3g=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=J8ERJn4Jjq3+9dxWIcWYFMLkEeYMMe1UKbX/mE3viuM1RfGcX79AC/YpEAQf3tzEFE ow9+lREmzGbvT8HWneO85X3+a2ByHc8hRhRXcirH9XTrGL6TXVaObGFMjAKyq3TKFktQ tELeD8cU4p+dzZLf/7UoetBunpkhMWk0/Q542JZoYFARL82GlL6glGLTuYlS55IDE0HV xE3Sa0gStcDAZaBW3rtWZ7ku4RO9y3IfxXgppWySnpv3TTh9SIM2Ba5T4EA9Rnz4lNqv yrAX2mdoL+pVOw8ewrlhPwpoO13nYfPDQYOfHQirl/5MS4XPT0Rf2oAhR4ILZS4znZxZ gScA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="En/XbSYb"; 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-35669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35669-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id oq41-20020a05620a612900b00783a08bdc2dsi4161347qkn.782.2024.01.23.08.42.51 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:42:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="En/XbSYb"; 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-35669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35669-ouuuleilei=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 095DC1C20CB4 for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 16:42:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 093FF1292C3; Tue, 23 Jan 2024 16:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="En/XbSYb" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 2FBBB80046; Tue, 23 Jan 2024 16:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027829; cv=none; b=P6eKtePJbOun7wXPcd16AETVBr9Otl42VQMD+H3FXlVyoYryFHTCAmOFgASxri5zBSTKiz5fH6psdXNCko3E/MIWXM9UipsGK5Wy6N51sEKE/a5j4Ox54CQbhq1YnmKRge7XrR/ysaJUsvo3GH5OefzI/zGi/NP8TcnYheGIN24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027829; c=relaxed/simple; bh=AOscs8QIG573GTnqalFMMwHtcQ8ONmRuwieK8uqlR40=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ryqcfJRfO5cYPeOLlz/ywwwWi/HdvmSoGxVTM+mRVyTwvSuKJNvmtAtLZJxot1vYfvp8tMPj7HLm7BhWH3wXFR0QLwWPuKWoGCpX2+PDot84eCqcfX+XyyuEXJdOogkSGG1kF0Ml7N9AIgmIH5Bc9e4VHGwYF8gY4qp4ocOqwKs= 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=En/XbSYb; arc=none smtp.client-ip=198.47.19.142 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 fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGax8N094134; Tue, 23 Jan 2024 10:36:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027819; bh=NynlMJZVVWmFK6HEqJQ06332dhB5iMXyjOa26cOux3g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=En/XbSYbkpAcJ6Xir3CNLJiY1RSv1Tblem41AtTRy3eVfDAYyubRm40jysHFe5o5e yR7dxzI1qPLHTXBJQ5jwyiTPbYEe/0eYi8DXg4GB4tIi4PfEnV8nFwypqppuesg6CP 6i/sCNkGkSQt4pv5UKakL8dTC5VASwYwq1MsjC+g= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGaxU5119736 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:36:59 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE111.ent.ti.com (10.64.6.32) 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:59 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE109.ent.ti.com (10.64.6.30) 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:59 -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 40NGars3123403; Tue, 23 Jan 2024 10:36:58 -0600 From: Andrew Davis <afd@ti.com> To: Sebastian Reichel <sre@kernel.org>, Support Opensource <support.opensource@diasemi.com>, Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= <pali@kernel.org> CC: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Andrew Davis <afd@ti.com> Subject: [PATCH 15/21] power: supply: wm8350: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:47 -0600 Message-ID: <20240123163653.384385-16-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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788900195310309642 X-GMAIL-MSGID: 1788900195310309642 |
Series |
Power supply register with devm
|
|
Commit Message
Andrew Davis
Jan. 23, 2024, 4:36 p.m. UTC
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 <afd@ti.com>
---
drivers/power/supply/wm8350_power.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
Comments
Hi Andrew,
kernel test robot noticed the following build warnings:
[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on linus/master v6.8-rc1 next-20240125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andrew-Davis/power-supply-da9030-Use-devm_power_supply_register-helper/20240124-004253
base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
patch link: https://lore.kernel.org/r/20240123163653.384385-16-afd%40ti.com
patch subject: [PATCH 15/21] power: supply: wm8350: Use devm_power_supply_register() helper
config: i386-buildonly-randconfig-004-20240126 (https://download.01.org/0day-ci/archive/20240126/202401262027.yOqHrHcD-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240126/202401262027.yOqHrHcD-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401262027.yOqHrHcD-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/power/supply/wm8350_power.c:573:23: warning: unused variable 'power' [-Wunused-variable]
573 | struct wm8350_power *power = &wm8350->power;
| ^~~~~
1 warning generated.
vim +/power +573 drivers/power/supply/wm8350_power.c
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 569
42720969f394dc drivers/power/supply/wm8350_power.c Uwe Kleine-König 2023-09-18 570 static void wm8350_power_remove(struct platform_device *pdev)
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 571 {
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 572 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 @573 struct wm8350_power *power = &wm8350->power;
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 574
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 575 free_charger_irq(wm8350);
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 576 device_remove_file(&pdev->dev, &dev_attr_charger_state);
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 577 }
14431aa0c5a443 drivers/power/wm8350_power.c Mark Brown 2008-11-16 578
diff --git a/drivers/power/supply/wm8350_power.c b/drivers/power/supply/wm8350_power.c index f23b4f5343bc1..9b0010b28cafc 100644 --- a/drivers/power/supply/wm8350_power.c +++ b/drivers/power/supply/wm8350_power.c @@ -540,22 +540,17 @@ static int wm8350_power_probe(struct platform_device *pdev) struct wm8350_charger_policy *policy = power->policy; int ret; - power->ac = power_supply_register(&pdev->dev, &wm8350_ac_desc, NULL); + power->ac = devm_power_supply_register(&pdev->dev, &wm8350_ac_desc, NULL); if (IS_ERR(power->ac)) return PTR_ERR(power->ac); - power->battery = power_supply_register(&pdev->dev, &wm8350_battery_desc, - NULL); - if (IS_ERR(power->battery)) { - ret = PTR_ERR(power->battery); - goto battery_failed; - } + power->battery = devm_power_supply_register(&pdev->dev, &wm8350_battery_desc, NULL); + if (IS_ERR(power->battery)) + return PTR_ERR(power->battery); - power->usb = power_supply_register(&pdev->dev, &wm8350_usb_desc, NULL); - if (IS_ERR(power->usb)) { - ret = PTR_ERR(power->usb); - goto usb_failed; - } + power->usb = devm_power_supply_register(&pdev->dev, &wm8350_usb_desc, NULL); + if (IS_ERR(power->usb)) + return PTR_ERR(power->usb); ret = device_create_file(&pdev->dev, &dev_attr_charger_state); if (ret < 0) @@ -569,13 +564,6 @@ static int wm8350_power_probe(struct platform_device *pdev) wm8350_reg_lock(wm8350); } - return ret; - -usb_failed: - power_supply_unregister(power->battery); -battery_failed: - power_supply_unregister(power->ac); - return ret; } @@ -586,9 +574,6 @@ static void wm8350_power_remove(struct platform_device *pdev) free_charger_irq(wm8350); device_remove_file(&pdev->dev, &dev_attr_charger_state); - power_supply_unregister(power->battery); - power_supply_unregister(power->ac); - power_supply_unregister(power->usb); } static struct platform_driver wm8350_power_driver = {