From: Andrew Davis <afd@ti.com>
To: Sebastian Reichel <sre@kernel.org>,
Support Opensource <support.opensource@diasemi.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andrew Davis <afd@ti.com>
Subject: [PATCH v2 2/4] power: supply: max77693: Use devm_power_supply_register() helper
Date: Mon, 29 Jan 2024 13:02:44 -0600 [thread overview]
Message-ID: <20240129190246.73067-3-afd@ti.com> (raw)
In-Reply-To: <20240129190246.73067-1-afd@ti.com>
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/max77693_charger.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c
index d0157e63b8b50..2001e12c9f7de 100644
--- a/drivers/power/supply/max77693_charger.c
+++ b/drivers/power/supply/max77693_charger.c
@@ -709,9 +709,9 @@ static int max77693_charger_probe(struct platform_device *pdev)
goto err;
}
- chg->charger = power_supply_register(&pdev->dev,
- &max77693_charger_desc,
- &psy_cfg);
+ chg->charger = devm_power_supply_register(&pdev->dev,
+ &max77693_charger_desc,
+ &psy_cfg);
if (IS_ERR(chg->charger)) {
dev_err(&pdev->dev, "failed: power supply register\n");
ret = PTR_ERR(chg->charger);
@@ -730,13 +730,9 @@ static int max77693_charger_probe(struct platform_device *pdev)
static void max77693_charger_remove(struct platform_device *pdev)
{
- struct max77693_charger *chg = platform_get_drvdata(pdev);
-
device_remove_file(&pdev->dev, &dev_attr_top_off_timer);
device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current);
device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer);
-
- power_supply_unregister(chg->charger);
}
static const struct platform_device_id max77693_charger_id[] = {
--
2.39.2
next prev parent reply other threads:[~2024-01-29 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 19:02 [PATCH v2 0/4] Power supply register with devm Andrew Davis
2024-01-29 19:02 ` [PATCH v2 1/4] power: supply: max14577: Use devm_power_supply_register() helper Andrew Davis
2024-01-29 19:02 ` Andrew Davis [this message]
2024-01-29 19:02 ` [PATCH v2 3/4] power: supply: max8925: " Andrew Davis
2024-01-29 19:02 ` [PATCH v2 4/4] power: supply: wm8350: " Andrew Davis
2024-02-01 21:51 ` [PATCH v2 0/4] Power supply register with devm Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240129190246.73067-3-afd@ti.com \
--to=afd@ti.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=support.opensource@diasemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox