Skip to content

Commit

Permalink
power: supply: axp288_fuel_gauge: Use devm_power_supply_register()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hans de Goede authored and Sebastian Reichel committed Feb 1, 2022
1 parent 3601086 commit f1b7e08
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/power/supply/axp288_fuel_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit f1b7e08

Please sign in to comment.