summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Davis <afd@ti.com>2024-01-23 10:36:53 -0600
committerSebastian Reichel <sebastian.reichel@collabora.com>2024-01-27 01:25:05 +0100
commit4c5d387d79a65355b73e526cbf5754a9dcd5377b (patch)
tree310ee4ebd6c9b027f31b4f80e8aa79ad0d9b5424 /drivers
parent8ac675344280a406835f03746594345209f2c1ae (diff)
downloadlinux-stable-4c5d387d79a65355b73e526cbf5754a9dcd5377b.tar.gz
linux-stable-4c5d387d79a65355b73e526cbf5754a9dcd5377b.tar.bz2
linux-stable-4c5d387d79a65355b73e526cbf5754a9dcd5377b.zip
power: supply: twl4030_madc: 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-22-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/supply/twl4030_madc_battery.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/drivers/power/supply/twl4030_madc_battery.c b/drivers/power/supply/twl4030_madc_battery.c
index cd9e94134ab2..3935162e350b 100644
--- a/drivers/power/supply/twl4030_madc_battery.c
+++ b/drivers/power/supply/twl4030_madc_battery.c
@@ -215,30 +215,21 @@ static int twl4030_madc_battery_probe(struct platform_device *pdev)
twl4030_cmp, NULL);
twl4030_madc_bat->pdata = pdata;
- platform_set_drvdata(pdev, twl4030_madc_bat);
psy_cfg.drv_data = twl4030_madc_bat;
- twl4030_madc_bat->psy = power_supply_register(&pdev->dev,
- &twl4030_madc_bat_desc,
- &psy_cfg);
+ twl4030_madc_bat->psy = devm_power_supply_register(&pdev->dev,
+ &twl4030_madc_bat_desc,
+ &psy_cfg);
if (IS_ERR(twl4030_madc_bat->psy))
return PTR_ERR(twl4030_madc_bat->psy);
return 0;
}
-static void twl4030_madc_battery_remove(struct platform_device *pdev)
-{
- struct twl4030_madc_battery *bat = platform_get_drvdata(pdev);
-
- power_supply_unregister(bat->psy);
-}
-
static struct platform_driver twl4030_madc_battery_driver = {
.driver = {
.name = "twl4030_madc_battery",
},
.probe = twl4030_madc_battery_probe,
- .remove_new = twl4030_madc_battery_remove,
};
module_platform_driver(twl4030_madc_battery_driver);