diff mbox series

[PATCHv1,04/11] power: supply: generic-adc-battery: fix unit scaling

Message ID 20230309225041.477440-5-sre@kernel.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Add DT support for generic ADC battery | expand

Commit Message

Sebastian Reichel March 9, 2023, 10:50 p.m. UTC
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.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/power/supply/generic-adc-battery.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Linus Walleij March 10, 2023, 8:23 a.m. UTC | #1
On Thu, Mar 9, 2023 at 11:50 PM Sebastian Reichel <sre@kernel.org> wrote:

> 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.
>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>

Fixes: tag?
Cc: stable@vger.kernel.org

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

This code can not have seen much testing.

Yours,
Linus Walleij
Matti Vaittinen March 13, 2023, 7:52 a.m. UTC | #2
On 3/10/23 00:50, Sebastian Reichel wrote:
> 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.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>

As Linus wrote, Fixes-tag would be good. With that remark:
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   drivers/power/supply/generic-adc-battery.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
> index 917bd2a6cc52..535972a332b3 100644
> --- a/drivers/power/supply/generic-adc-battery.c
> +++ b/drivers/power/supply/generic-adc-battery.c
> @@ -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;
>   }
>
Sebastian Reichel March 13, 2023, 11:17 p.m. UTC | #3
Hi,

On Fri, Mar 10, 2023 at 09:23:06AM +0100, Linus Walleij wrote:
> On Thu, Mar 9, 2023 at 11:50 PM Sebastian Reichel <sre@kernel.org> wrote:
> 
> > 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.
> >
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> 
> Fixes: tag?
> Cc: stable@vger.kernel.org
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> This code can not have seen much testing.

There is no mainline board using this driver and I think there
never was one. I did add a Fixes tag now, but its probably not worth
any backporting trouble considering it has no users.

-- Sebastian
Linus Walleij March 14, 2023, 8:14 a.m. UTC | #4
On Tue, Mar 14, 2023 at 12:17 AM Sebastian Reichel <sre@kernel.org> wrote:

> There is no mainline board using this driver and I think there
> never was one. I did add a Fixes tag now, but its probably not worth
> any backporting trouble considering it has no users.

Good point. If a tree falls in the wood an no-one is there to hear it,
it doesn't make a sound.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
index 917bd2a6cc52..535972a332b3 100644
--- a/drivers/power/supply/generic-adc-battery.c
+++ b/drivers/power/supply/generic-adc-battery.c
@@ -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;
 }