From 01da1f4a6373f8d6a5a2d5d5adc256431087ccc4 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 26 Jul 2026 21:13:02 -0400 Subject: [PATCH] power: supply: max17042_battery: Convert initialization to delayed work Periodic MAX17055 retries need a delayed work item. Convert the existing initialization work in advance without adding retries or changing when the first attempt runs. Use schedule_delayed_work() with a zero delay so the work continues to run on system_wq, matching schedule_work() rather than introducing a separate workqueue policy change. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier Link: https://patch.msgid.link/20260727011319.621794-5-vincent.cloutier@icloud.com Signed-off-by: Sebastian Reichel --- drivers/power/supply/max17042_battery.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 91a55c30667f..bfc563ff9c31 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -69,7 +69,7 @@ struct max17042_chip { struct power_supply *battery; enum max170xx_chip_type chip_type; struct max17042_config_data *config_data; - struct work_struct work; + struct delayed_work work; int irq; int task_period; bool enable_current_sense; @@ -996,7 +996,7 @@ static irqreturn_t max17042_thread_handler(int id, void *dev) static void max17042_init_worker(struct work_struct *work) { - struct max17042_chip *chip = container_of(work, + struct max17042_chip *chip = container_of(to_delayed_work(work), struct max17042_chip, work); int ret; @@ -1255,11 +1255,11 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq regmap_read(chip->regmap, MAX17042_STATUS, &val); if (val & STATUS_POR_BIT) { - ret = devm_work_autocancel(dev, &chip->work, - max17042_init_worker); + ret = devm_delayed_work_autocancel(dev, &chip->work, + max17042_init_worker); if (ret) return ret; - schedule_work(&chip->work); + schedule_delayed_work(&chip->work, 0); } else { WRITE_ONCE(chip->init_complete, true); }