power: supply: sbs-battery: don't assume i2c errors as battery disconnect
authorIkjoon Jang <ikjn@chromium.org>
Fri, 28 Aug 2020 04:36:26 +0000 (12:36 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Fri, 28 Aug 2020 15:25:54 +0000 (17:25 +0200)
commit395a7251dc2bf5eed2aab6960720a270b364871e
tree92a306a255ae4980640723d15691d23c04ec71c3
parentf385e2fcc596f0c4428d3c519e524f3709654f3b
power: supply: sbs-battery: don't assume i2c errors as battery disconnect

Current sbs-battery considers all smbus errors as disconnection events
when battery-detect pin isn't supplied, and restored to present state back
when any successful transaction is made.

This can lead to unwanted state changes between present and !present
when there's one i2c error and other following commands were successful.

This patch provides a unified way of checking presence by calling
sbs_get_battery_presence_and_health() when detect pin is not used.

Signed-off-by: Ikjoon Jang <ikjn@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/sbs-battery.c