Skip to content

Commit a7aaa80

Browse files
jwrdegoedesre
authored andcommitted
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: 48f45b0 ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol") Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 54c03bf commit a7aaa80

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/power/supply/bq25890_charger.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,13 @@ static int bq25890_fw_probe(struct bq25890_device *bq)
13171317
return 0;
13181318
}
13191319

1320+
static void bq25890_non_devm_cleanup(void *data)
1321+
{
1322+
struct bq25890_device *bq = data;
1323+
1324+
cancel_delayed_work_sync(&bq->pump_express_work);
1325+
}
1326+
13201327
static int bq25890_probe(struct i2c_client *client)
13211328
{
13221329
struct device *dev = &client->dev;
@@ -1372,6 +1379,14 @@ static int bq25890_probe(struct i2c_client *client)
13721379
/* OTG reporting */
13731380
bq->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
13741381

1382+
/*
1383+
* This must be before bq25890_power_supply_init(), so that it runs
1384+
* after devm unregisters the power_supply.
1385+
*/
1386+
ret = devm_add_action_or_reset(dev, bq25890_non_devm_cleanup, bq);
1387+
if (ret)
1388+
return ret;
1389+
13751390
ret = bq25890_register_regulator(bq);
13761391
if (ret)
13771392
return ret;

0 commit comments

Comments
 (0)