Commit 1530dcc9 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

power: supply: axp288_charger: Properly stop work on probe-error / remove


[ Upstream commit 165c2357 ]

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: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 87b9099c
...@@ -785,6 +785,14 @@ static int charger_init_hw_regs(struct axp288_chrg_info *info) ...@@ -785,6 +785,14 @@ static int charger_init_hw_regs(struct axp288_chrg_info *info)
return 0; 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) static int axp288_charger_probe(struct platform_device *pdev)
{ {
int ret, i, pirq; int ret, i, pirq;
...@@ -836,6 +844,11 @@ static int axp288_charger_probe(struct platform_device *pdev) ...@@ -836,6 +844,11 @@ static int axp288_charger_probe(struct platform_device *pdev)
return ret; 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 */ /* Register for extcon notification */
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
info->cable.nb[0].notifier_call = axp288_charger_handle_cable0_evt; info->cable.nb[0].notifier_call = axp288_charger_handle_cable0_evt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment