diff options
author | Andrew Davis <afd@ti.com> | 2024-01-23 19:36:49 +0300 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2024-01-27 03:25:05 +0300 |
commit | 077c1df8456f97d89e4880ba503d8ddf6af5be12 (patch) | |
tree | 36cbd7737ab2259d4ecb1fb8d6b62b26be41d744 /drivers/power | |
parent | 9115c677071a09cf51cace59c33ed71ec61bdfec (diff) | |
download | linux-077c1df8456f97d89e4880ba503d8ddf6af5be12.tar.xz |
power: supply: da9150: 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-18-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/da9150-charger.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/power/supply/da9150-charger.c b/drivers/power/supply/da9150-charger.c index 77e2d42382e4..b13cecd84f58 100644 --- a/drivers/power/supply/da9150-charger.c +++ b/drivers/power/supply/da9150-charger.c @@ -538,15 +538,13 @@ static int da9150_charger_probe(struct platform_device *pdev) return PTR_ERR(charger->vbat_chan); /* Register power supplies */ - charger->usb = power_supply_register(dev, &usb_desc, NULL); + charger->usb = devm_power_supply_register(dev, &usb_desc, NULL); if (IS_ERR(charger->usb)) return PTR_ERR(charger->usb); - charger->battery = power_supply_register(dev, &battery_desc, NULL); - if (IS_ERR(charger->battery)) { - ret = PTR_ERR(charger->battery); - goto battery_fail; - } + charger->battery = devm_power_supply_register(dev, &battery_desc, NULL); + if (IS_ERR(charger->battery)) + return PTR_ERR(charger->battery); /* Get initial online supply */ reg = da9150_reg_read(da9150, DA9150_STATUS_H); @@ -606,8 +604,6 @@ tjunc_irq_fail: chg_irq_fail: if (!IS_ERR_OR_NULL(charger->usb_phy)) usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); -battery_fail: - power_supply_unregister(charger->usb); return ret; } @@ -633,9 +629,6 @@ static void da9150_charger_remove(struct platform_device *pdev) if (!IS_ERR_OR_NULL(charger->usb_phy)) usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); cancel_work_sync(&charger->otg_work); - - power_supply_unregister(charger->battery); - power_supply_unregister(charger->usb); } static struct platform_driver da9150_charger_driver = { |