diff options
author | Andrew Davis <afd@ti.com> | 2024-01-23 19:36:45 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2024-01-27 03:25:04 +0300 |
commit | aa0c8959dac7207e3b7b25bcb01730bff9c61713 (patch) | |
tree | 6f70501f5d5271103304d451ea37c76df38daa5d /drivers/power | |
parent | 503920abb586c3e355a19c680089ff5b33d97262 (diff) | |
download | linux-aa0c8959dac7207e3b7b25bcb01730bff9c61713.tar.xz |
power: supply: wm831x: 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-14-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/wm831x_backup.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/drivers/power/supply/wm831x_backup.c b/drivers/power/supply/wm831x_backup.c index 1a7265660ade..9673fcf7f3af 100644 --- a/drivers/power/supply/wm831x_backup.c +++ b/drivers/power/supply/wm831x_backup.c @@ -171,7 +171,6 @@ static int wm831x_backup_probe(struct platform_device *pdev) return -ENOMEM; devdata->wm831x = wm831x; - platform_set_drvdata(pdev, devdata); /* We ignore configuration failures since we can still read * back the status without enabling the charger (which may @@ -191,22 +190,14 @@ static int wm831x_backup_probe(struct platform_device *pdev) devdata->backup_desc.properties = wm831x_backup_props; devdata->backup_desc.num_properties = ARRAY_SIZE(wm831x_backup_props); devdata->backup_desc.get_property = wm831x_backup_get_prop; - devdata->backup = power_supply_register(&pdev->dev, - &devdata->backup_desc, NULL); + devdata->backup = devm_power_supply_register(&pdev->dev, + &devdata->backup_desc, NULL); return PTR_ERR_OR_ZERO(devdata->backup); } -static void wm831x_backup_remove(struct platform_device *pdev) -{ - struct wm831x_backup *devdata = platform_get_drvdata(pdev); - - power_supply_unregister(devdata->backup); -} - static struct platform_driver wm831x_backup_driver = { .probe = wm831x_backup_probe, - .remove_new = wm831x_backup_remove, .driver = { .name = "wm831x-backup", }, |