Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v1 0/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion
@ 2026-09-26 14:29 Svyatoslav Ryhel
  2026-09-26 14:29 ` [PATCH v1 1/1] " Svyatoslav Ryhel
  0 siblings, 1 reply; 3+ messages in thread
From: Svyatoslav Ryhel @ 2026-09-26 14:29 UTC (permalink / raw)
  To: Sebastian Reichel, Linus Walleij, Matti Vaittinen; +Cc: linux-pm, linux-kernel

Temperature IIO channel data is provided in milli-degrees, while
POWER_SUPPLY_PROP_TEMP is expected to be in deci-degrees. Adjust the
existing logic to reflect this conversion properly.

Svyatoslav Ryhel (1):
  power: supply: generic-adc-battery: Fix temperature IIO channel
    conversion

 drivers/power/supply/generic-adc-battery.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 1/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion
  2026-09-26 14:29 [PATCH v1 0/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion Svyatoslav Ryhel
@ 2026-09-26 14:29 ` Svyatoslav Ryhel
  2026-10-04 17:47   ` Sebastian Reichel
  0 siblings, 1 reply; 3+ messages in thread
From: Svyatoslav Ryhel @ 2026-09-26 14:29 UTC (permalink / raw)
  To: Sebastian Reichel, Linus Walleij, Matti Vaittinen; +Cc: linux-pm, linux-kernel

Temperature IIO channel data is provided in milli-degrees, while
POWER_SUPPLY_PROP_TEMP is expected to be in deci-degrees. Adjust the
existing logic to reflect this conversion properly.

Fixes: 33088c0513818 ("power: supply: generic-adc-battery: add temperature support")
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/power/supply/generic-adc-battery.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
index 185f55d2fd709..f11a5c794e7e8 100644
--- a/drivers/power/supply/generic-adc-battery.c
+++ b/drivers/power/supply/generic-adc-battery.c
@@ -90,12 +90,17 @@ static int gab_read_channel(struct gab *adc_bat, enum gab_chan_type channel,
 	int ret;
 
 	ret = iio_read_channel_processed(adc_bat->channel[channel], result);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&adc_bat->psy->dev, "read channel error: %d\n", ret);
+		return ret;
+	}
+
+	if (channel == GAB_TEMP)
+		*result /= 100; /* Convert from milli- to deci-degree */
 	else
 		*result *= 1000;
 
-	return ret;
+	return 0;
 }
 
 static int gab_get_property(struct power_supply *psy,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion
  2026-09-26 14:29 ` [PATCH v1 1/1] " Svyatoslav Ryhel
@ 2026-10-04 17:47   ` Sebastian Reichel
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2026-10-04 17:47 UTC (permalink / raw)
  To: Sebastian Reichel, Linus Walleij, Matti Vaittinen,
	Svyatoslav Ryhel
  Cc: linux-pm, linux-kernel


On Sat, 26 Sep 2026 17:29:05 +0300, Svyatoslav Ryhel wrote:
> Temperature IIO channel data is provided in milli-degrees, while
> POWER_SUPPLY_PROP_TEMP is expected to be in deci-degrees. Adjust the
> existing logic to reflect this conversion properly.

Applied, thanks!

[1/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion
      commit: 6bca94e64255053ab2aa56f2588fda73d399b790

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-04 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-26 14:29 [PATCH v1 0/1] power: supply: generic-adc-battery: Fix temperature IIO channel conversion Svyatoslav Ryhel
2026-09-26 14:29 ` [PATCH v1 1/1] " Svyatoslav Ryhel
2026-10-04 17:47   ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox