From e8e7cdd9ce46a763e5428e2673e90c6a5f91f6d8 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 26 Jul 2026 21:13:01 -0400 Subject: [PATCH] power: supply: max17042_battery: Use bool for init_complete init_complete is a binary state. Change it from int to bool before adding retry support. The initialization worker and probe path update the flag while property reads sample it. Use READ_ONCE() and WRITE_ONCE() to make those lockless accesses explicit. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier Link: https://patch.msgid.link/20260727011319.621794-4-vincent.cloutier@icloud.com Signed-off-by: Sebastian Reichel --- drivers/power/supply/max17042_battery.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 16b7ef52419d..91a55c30667f 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -70,11 +70,11 @@ struct max17042_chip { enum max170xx_chip_type chip_type; struct max17042_config_data *config_data; struct work_struct work; - int init_complete; int irq; int task_period; bool enable_current_sense; bool enable_por_init; + bool init_complete; unsigned int r_sns; int vmin; /* in millivolts */ int vmax; /* in millivolts */ @@ -257,7 +257,7 @@ static int max17042_get_property(struct power_supply *psy, u32 data; u64 data64; - if (!chip->init_complete) + if (!READ_ONCE(chip->init_complete)) return -EAGAIN; switch (psp) { @@ -1007,7 +1007,7 @@ static void max17042_init_worker(struct work_struct *work) return; } - chip->init_complete = 1; + WRITE_ONCE(chip->init_complete, true); } #ifdef CONFIG_OF @@ -1261,7 +1261,7 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq return ret; schedule_work(&chip->work); } else { - chip->init_complete = 1; + WRITE_ONCE(chip->init_complete, true); } return 0;