]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
power: supply: bq27xxx: fix power_avg for newer ICs
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Wed, 3 Mar 2021 09:54:19 +0000 (10:54 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:32:08 +0000 (10:32 +0200)
commit27deda28eb7c9805d7f9a766c55b41a1a611f721
tree22760d2c2a8fb89cef1b3ef07360036a207ed817
parentcb41578cd1be4003b12b33356e5328e738137321
power: supply: bq27xxx: fix power_avg for newer ICs

BugLink: https://bugs.launchpad.net/bugs/1928857
[ Upstream commit c4d57c22ac65bd503716062a06fad55a01569cac ]

On all newer bq27xxx ICs, the AveragePower register contains a signed
value; in addition to handling the raw value as unsigned, the driver
code also didn't convert it to µW as expected.

At least for the BQ28Z610, the reference manual incorrectly states that
the value is in units of 1mW and not 10mW. I have no way of knowing
whether the manuals of other supported ICs contain the same error, or if
there are models that actually use 1mW. At least, the new code shouldn't
be *less* correct than the old version for any device.

power_avg is removed from the cache structure, se we don't have to
extend it to store both a signed value and an error code. Always getting
an up-to-date value may be desirable anyways, as it avoids inconsistent
current and power readings when switching between charging and
discharging.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/power/supply/bq27xxx_battery.c
include/linux/power/bq27xxx_battery.h