]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
power: supply: axp20x_battery: properly report current when discharging
authorEvgeny Boger <boger@wirenboard.com>
Wed, 12 Jan 2022 08:47:27 +0000 (11:47 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 18:02:59 +0000 (20:02 +0200)
commitf446a9e73940fcd997fcb92d16554849fdfb65de
treea3d1a8be4eb63bee71a2eca895ddf9b43c5d0805
parent7df9d090d96bfd1f7b4847332f174e0438ad102f
power: supply: axp20x_battery: properly report current when discharging

[ Upstream commit d4f408cdcd26921c1268cb8dcbe8ffb6faf837f3 ]

As stated in [1], negative current values are used for discharging
batteries.

AXP PMICs internally have two different ADC channels for shunt current
measurement: one used during charging and one during discharging.
The values reported by these ADCs are unsigned.
While the driver properly selects ADC channel to get the data from,
it doesn't apply negative sign when reporting discharging current.

[1] Documentation/ABI/testing/sysfs-class-power

Signed-off-by: Evgeny Boger <boger@wirenboard.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/axp20x_battery.c