diff options
author | Andrew Davis <afd@ti.com> | 2024-01-23 19:36:36 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2024-01-27 03:23:40 +0300 |
commit | ada63f1ec91b77417cf195dadd646eaadb6f121c (patch) | |
tree | 31023e2170683e8cbd5ea9ec5bf6b222405658c5 /drivers/power/supply | |
parent | 88a72257a438375894de446885bb40946e0f979f (diff) | |
download | linux-ada63f1ec91b77417cf195dadd646eaadb6f121c.tar.xz |
power: supply: goldfish: 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-5-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r-- | drivers/power/supply/goldfish_battery.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c index 8bb645ad1e5d..479195e35d73 100644 --- a/drivers/power/supply/goldfish_battery.c +++ b/drivers/power/supply/goldfish_battery.c @@ -232,31 +232,22 @@ static int goldfish_battery_probe(struct platform_device *pdev) psy_cfg.drv_data = data; - data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg); + data->ac = devm_power_supply_register(&pdev->dev, + &ac_desc, + &psy_cfg); if (IS_ERR(data->ac)) return PTR_ERR(data->ac); - data->battery = power_supply_register(&pdev->dev, &battery_desc, - &psy_cfg); - if (IS_ERR(data->battery)) { - power_supply_unregister(data->ac); + data->battery = devm_power_supply_register(&pdev->dev, + &battery_desc, + &psy_cfg); + if (IS_ERR(data->battery)) return PTR_ERR(data->battery); - } - - platform_set_drvdata(pdev, data); GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK); return 0; } -static void goldfish_battery_remove(struct platform_device *pdev) -{ - struct goldfish_battery_data *data = platform_get_drvdata(pdev); - - power_supply_unregister(data->battery); - power_supply_unregister(data->ac); -} - static const struct of_device_id goldfish_battery_of_match[] = { { .compatible = "google,goldfish-battery", }, {}, @@ -273,7 +264,6 @@ MODULE_DEVICE_TABLE(acpi, goldfish_battery_acpi_match); static struct platform_driver goldfish_battery_device = { .probe = goldfish_battery_probe, - .remove_new = goldfish_battery_remove, .driver = { .name = "goldfish-battery", .of_match_table = goldfish_battery_of_match, |