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 <vincent@cloutier.co>
Link: https://patch.msgid.link/20260727011319.621794-5-vincent.cloutier@icloud.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Vincent Cloutier 2026-07-26 21:13:02 -04:00 committed by Sebastian Reichel
parent e8e7cdd9ce
commit 01da1f4a63

View File

@ -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);
}