All of
 help / color / mirror / Atom feed
From: Chris Lesiak <>
To: Linus Walleij <>,
	Jean Delvare <>,
	Guenter Roeck <>
Cc: "" <>,
	Peter Rosin <>, Jonathan Cameron <>,
	"" <>
Subject: Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed
Date: Thu, 24 Dec 2020 03:15:55 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

A closer reading of the "iio: inkern: pass through raw values if no scaling"
commit leads me to believe that even when the sensor provides no scale,
the returned value is expected to be in the correct units.

If that is true, there was a bug in the commit.
It failed to apply the caller supplied scale that ntc_thermistor.c relies on
to convert from milliVolts to microVolts.

Linus, would this change address your original problem?

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index fe30bcb6a57b..79787474d511 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -587,7 +587,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
                 * Just pass raw values as processed if no scaling is
                 * available.
-               *processed = raw;
+               *processed = raw * scale;
                return 0;

From: Chris Lesiak <>
Sent: Wednesday, December 23, 2020 7:39 PM
To: Linus Walleij <>; Jean Delvare <>; Guenter Roeck <>
Cc: <>; Peter Rosin <>; Jonathan Cameron <>; <>
Subject: Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed 
Please don't use iio_read_channel_processed and convert from milliVolts to
microVolts by multiplying by 1000.  My use case requires the additional
precision that iio_read_channel_raw followed by iio_convert_raw_to_processed
with the 1000X scaler provides.

But I'm unsure about keeping the fallback 12-bit ADC in place.  I kept it so as
not to break Naveen Krishna Chatradhi's use case.  But I'm not sure it still works
after commit adc8ec5ff183d09ae7a9d2dd31125401d302ba63
"iio: inkern: pass through raw values if no scaling".  Before the commit,
iio_convert_raw_to_processed returned a negative number if there was no
scaling available.  Now, it returns the raw value.
Does that mean that the raw value is already scaled to the correct units?
Or does that mean that the scale is unknown and all you get is counts?

  reply	other threads:[~2020-12-24  3:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24  1:16 [PATCH v2] hwmon: (ntc_thermistor): try reading processed Linus Walleij
2020-12-24  1:39 ` Chris Lesiak
2020-12-24  3:15   ` Chris Lesiak [this message]
2020-12-25 23:01     ` Linus Walleij
2020-12-25 22:55   ` Linus Walleij
2020-12-26  1:45     ` Chris Lesiak
2020-12-27 13:46       ` Linus Walleij
2020-12-27 18:54         ` Chris Lesiak
2020-12-27 21:47           ` Linus Walleij
2020-12-27 22:08             ` Chris Lesiak
2020-12-29 14:25               ` Jonathan Cameron
2020-12-29 16:33                 ` Guenter Roeck
2020-12-29 16:53                   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.