[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202211519.199635-4-afd@ti.com>
Date: Mon, 2 Dec 2024 15:15:18 -0600
From: Andrew Davis <afd@...com>
To: Sebastian Reichel <sre@...nel.org>
CC: <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Andrew Davis
<afd@...com>
Subject: [PATCH 4/5] power: supply: ds2782: Use devm_power_supply_register() helper
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@...com>
---
drivers/power/supply/ds2782_battery.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/ds2782_battery.c b/drivers/power/supply/ds2782_battery.c
index a72d8c26650d7..ea687b9703314 100644
--- a/drivers/power/supply/ds2782_battery.c
+++ b/drivers/power/supply/ds2782_battery.c
@@ -314,7 +314,6 @@ static void ds278x_battery_remove(struct i2c_client *client)
{
struct ds278x_info *info = i2c_get_clientdata(client);
- power_supply_unregister(info->battery);
cancel_delayed_work_sync(&info->bat_work);
}
@@ -415,8 +414,9 @@ static int ds278x_battery_probe(struct i2c_client *client)
INIT_DELAYED_WORK(&info->bat_work, ds278x_bat_work);
- info->battery = power_supply_register(&client->dev,
- &info->battery_desc, &psy_cfg);
+ info->battery = devm_power_supply_register(&client->dev,
+ &info->battery_desc,
+ &psy_cfg);
if (IS_ERR(info->battery)) {
dev_err(&client->dev, "failed to register battery\n");
return PTR_ERR(info->battery);
--
2.39.2
Powered by blists - more mailing lists