diff options
author | Andrew Davis <afd@ti.com> | 2024-01-23 19:36:35 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2024-01-27 03:23:40 +0300 |
commit | 88a72257a438375894de446885bb40946e0f979f (patch) | |
tree | c82db9fe04ee06ec316b4a7d63b696416154f445 /drivers/power/supply | |
parent | 57261cda154b3d0f8671ea222672f75b1e965c15 (diff) | |
download | linux-88a72257a438375894de446885bb40946e0f979f.tar.xz |
power: supply: ds2760: 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@ti.com>
Link: https://lore.kernel.org/r/20240123163653.384385-4-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r-- | drivers/power/supply/ds2760_battery.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c index 40fba31be174..7cf4ea06b500 100644 --- a/drivers/power/supply/ds2760_battery.c +++ b/drivers/power/supply/ds2760_battery.c @@ -739,7 +739,7 @@ static int w1_ds2760_add_slave(struct w1_slave *sl) if (current_accum) ds2760_battery_set_current_accum(di, current_accum); - di->bat = power_supply_register(dev, &di->bat_desc, &psy_cfg); + di->bat = devm_power_supply_register(dev, &di->bat_desc, &psy_cfg); if (IS_ERR(di->bat)) { dev_err(di->dev, "failed to register battery\n"); retval = PTR_ERR(di->bat); @@ -762,7 +762,6 @@ static int w1_ds2760_add_slave(struct w1_slave *sl) goto success; workqueue_failed: - power_supply_unregister(di->bat); batt_failed: di_alloc_failed: success: @@ -777,7 +776,6 @@ static void w1_ds2760_remove_slave(struct w1_slave *sl) cancel_delayed_work_sync(&di->monitor_work); cancel_delayed_work_sync(&di->set_charged_work); destroy_workqueue(di->monitor_wqueue); - power_supply_unregister(di->bat); } #ifdef CONFIG_OF |