mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 02:19:54 +00:00
power: supply: bq25890: Ensure pump_express_work is cancelled on remove
The pump_express_work which gets queued from an external_power_changed
callback might be pending / running on remove() (or on probe failure).
Add a devm action cancelling the work, to ensure that it is cancelled.
Note the devm action is added before devm_power_supply_register(), making
it run after devm unregisters the power_supply, so that the work cannot
be queued anymore (this is also why a devm action is used for this).
Fixes: 48f45b094d ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol")
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
committed by
Sebastian Reichel
parent
54c03bfd09
commit
a7aaa80098
@@ -1317,6 +1317,13 @@ static int bq25890_fw_probe(struct bq25890_device *bq)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void bq25890_non_devm_cleanup(void *data)
|
||||||
|
{
|
||||||
|
struct bq25890_device *bq = data;
|
||||||
|
|
||||||
|
cancel_delayed_work_sync(&bq->pump_express_work);
|
||||||
|
}
|
||||||
|
|
||||||
static int bq25890_probe(struct i2c_client *client)
|
static int bq25890_probe(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct device *dev = &client->dev;
|
struct device *dev = &client->dev;
|
||||||
@@ -1372,6 +1379,14 @@ static int bq25890_probe(struct i2c_client *client)
|
|||||||
/* OTG reporting */
|
/* OTG reporting */
|
||||||
bq->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
|
bq->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This must be before bq25890_power_supply_init(), so that it runs
|
||||||
|
* after devm unregisters the power_supply.
|
||||||
|
*/
|
||||||
|
ret = devm_add_action_or_reset(dev, bq25890_non_devm_cleanup, bq);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ret = bq25890_register_regulator(bq);
|
ret = bq25890_register_regulator(bq);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user