Skip to content

Commit

Permalink
power: supply: axp288_charger: Properly stop work on probe-error / re…
Browse files Browse the repository at this point in the history
…move

Properly stop any work we may have queued on probe-errors / remove.

Rather then adding a remove driver callback for this, and goto style
error handling to probe, use a devm_action for this.

The devm_action gets registered before we register any of the extcon
notifiers which may queue the work, devm does cleanup in reverse order,
so this ensures that the notifiers are removed before we cancel the work.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
  • Loading branch information
Hans de Goede authored and Sebastian Reichel committed Jan 8, 2018
1 parent 8c0a0a2 commit 165c235
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/power/supply/axp288_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,14 @@ static int charger_init_hw_regs(struct axp288_chrg_info *info)
return 0;
}

static void axp288_charger_cancel_work(void *data)
{
struct axp288_chrg_info *info = data;

cancel_work_sync(&info->otg.work);
cancel_work_sync(&info->cable.work);
}

static int axp288_charger_probe(struct platform_device *pdev)
{
int ret, i, pirq;
Expand Down Expand Up @@ -772,6 +780,11 @@ static int axp288_charger_probe(struct platform_device *pdev)
return ret;
}

/* Cancel our work on cleanup, register this before the notifiers */
ret = devm_add_action(dev, axp288_charger_cancel_work, info);
if (ret)
return ret;

/* Register for extcon notification */
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
Expand Down

0 comments on commit 165c235

Please sign in to comment.