Hi, On Fri, Jul 24, 2026 at 05:47:59PM +0800, Jianing Li wrote: > max17040_get_vcell() and max17040_get_soc() ignore errors returned by > regmap_read(). When an I2C transfer fails, the uninitialized register > value is converted and reported to userspace as a valid voltage or state > of charge. The polling worker can also replace the cached state of charge > with the bogus value and emit a spurious change event. > > Propagate read errors through the power supply get_property callback and > keep the last valid cached state of charge when polling fails. > > Fixes: c6f4a42de60b ("Add MAX17040 Fuel Gauge driver") > Cc: stable@vger.kernel.org > Signed-off-by: Jianing Li > --- > drivers/power/supply/max17040_battery.c | 26 +++++++++++++++++++------- > 1 file changed, 19 insertions(+), 7 deletions(-) > > diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c > index e94d53b36aa4..948670fb6c4a 100644 > --- a/drivers/power/supply/max17040_battery.c > +++ b/drivers/power/supply/max17040_battery.c > @@ -192,19 +192,21 @@ static int max17040_raw_vcell_to_uvolts(struct max17040_chip *chip, u16 vcell) > static int max17040_get_vcell(struct max17040_chip *chip) > { > u32 vcell; > + int ret; > > - regmap_read(chip->regmap, MAX17040_VCELL, &vcell); > + ret = regmap_read(chip->regmap, MAX17040_VCELL, &vcell); > > - return max17040_raw_vcell_to_uvolts(chip, vcell); > + return ret ? ret : max17040_raw_vcell_to_uvolts(chip, vcell); Please follow the common convention, i.e. ret = foo(); if (ret) return ret; return bar(); Greetings, -- Sebastian