]> git.dujemihanovic.xyz Git - linux.git/commitdiff
power: supply: generic-adc-battery: fix unit scaling
authorSebastian Reichel <sre@kernel.org>
Fri, 17 Mar 2023 22:56:57 +0000 (23:56 +0100)
committerSebastian Reichel <sre@kernel.org>
Wed, 29 Mar 2023 20:38:56 +0000 (22:38 +0200)
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>
drivers/power/supply/generic-adc-battery.c

index 917bd2a6cc5204afa6aebc4e43f1211c20ea0a02..535972a332b32f65960b63a6b5660125edf91d71 100644 (file)
@@ -136,6 +136,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;
 }