summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2022-01-06 12:06:05 +0100
committerSebastian Reichel <sebastian.reichel@collabora.com>2022-02-01 14:29:34 +0100
commitf1b7e0881fe12ebd2d95f55ebf4fcf57566a53b6 (patch)
treebae0ba1de5d85d023b0d8ce8157d5f913cfcd9a5
parent360108661277a784aacb22913b853e9b0fc4de1c (diff)
power: supply: axp288_fuel_gauge: Use devm_power_supply_register()
Use devm_power_supply_register() instead of power_supply_register(). Note as a side-effect this changes the release order so that now first the IRQs get free-ed and then the psy gets unregistered. This is actually a bug-fix since this fixes the IRQ possibly trying to reference the unregistered psy. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r--drivers/power/supply/axp288_fuel_gauge.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index aaf2d5542316..cefde85e3309 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -740,7 +740,7 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
return ret;
psy_cfg.drv_data = info;
- info->bat = power_supply_register(dev, &fuel_gauge_desc, &psy_cfg);
+ info->bat = devm_power_supply_register(dev, &fuel_gauge_desc, &psy_cfg);
if (IS_ERR(info->bat)) {
ret = PTR_ERR(info->bat);
dev_err(dev, "failed to register battery: %d\n", ret);
@@ -763,8 +763,6 @@ static int axp288_fuel_gauge_remove(struct platform_device *pdev)
struct axp288_fg_info *info = platform_get_drvdata(pdev);
int i;
- power_supply_unregister(info->bat);
-
for (i = 0; i < AXP288_FG_INTR_NUM; i++)
if (info->irq[i] >= 0)
free_irq(info->irq[i], info);