aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorSebastian Reichel2023-03-17 23:56:57 +0100
committerGreg Kroah-Hartman2023-05-11 23:03:33 +0900
commita2b3eaaa97826fa3b55d46d03777460302605977 (patch)
tree81b3540a77e5a3a4438ccbb2aa942f1e64a742bb /drivers/power
parent37f689d859ee6a504f0cbe7c9a38babaa5ee6191 (diff)
power: supply: generic-adc-battery: fix unit scaling
[ Upstream commit 44263f50065969f2344808388bd589740f026167 ] power-supply properties are reported in µV, µA and µW. The IIO API provides mV, mA, mW, so the values need to be multiplied by 1000. Fixes: e60fea794e6e ("power: battery: Generic battery driver using IIO") Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/generic-adc-battery.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
index 66039c665dd1..0af536f4932f 100644
--- a/drivers/power/supply/generic-adc-battery.c
+++ b/drivers/power/supply/generic-adc-battery.c
@@ -135,6 +135,9 @@ static int read_channel(struct gab *adc_bat, enum power_supply_property psp,
result);
if (ret < 0)
pr_err("read channel error\n");
+ else
+ *result *= 1000;
+
return ret;
}