mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 06:01:53 +02:00
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>
This commit is contained in:
parent
88a72257a4
commit
ada63f1ec9
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user