]> www.infradead.org Git - linux.git/commit
power: supply: bq27xxx: Retrieve again when busy
authorJerry Lv <Jerry.Lv@axis.com>
Tue, 15 Apr 2025 03:40:47 +0000 (11:40 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sun, 27 Apr 2025 22:24:52 +0000 (00:24 +0200)
commitf16d9fb6cf03fdbdefa41a8b32ba1e57afb7ae3d
treeb60d1fc02babaa9121552e42fda1cf1db24eff4a
parent1e3e2cf2df60521eee257b2c77a8f0d8594242ff
power: supply: bq27xxx: Retrieve again when busy

Multiple applications may access the battery gauge at the same time, so
the gauge may be busy and EBUSY will be returned. The driver will set a
flag to record the EBUSY state, and this flag will be kept until the next
periodic update. When this flag is set, bq27xxx_battery_get_property()
will just return ENODEV until the flag is updated.

Even if the gauge was busy during the last accessing attempt, returning
ENODEV is not ideal, and can cause confusion in the applications layer.

Instead, retry accessing the I2C to update the flag is as expected, for
the gauge typically recovers from busy state within a few milliseconds.
If still failed to access the gauge, the real error code would be returned
instead of ENODEV (as suggested by Pali Rohár).

Reviewed-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Jerry Lv <Jerry.Lv@axis.com>
Link: https://lore.kernel.org/r/20250415-foo-fix-v2-1-5b45a395e4cc@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq27xxx_battery.c
drivers/power/supply/bq27xxx_battery_i2c.c