Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <chris.lesiak@xxxxxxxxx>
Sent: Wednesday, December 23, 2020 7:39 PM
To: Linus Walleij <linus.walleij@xxxxxxxxxx>; Jean Delvare <jdelvare@xxxxxxxx>; Guenter Roeck <linux@xxxxxxxxxxxx>
Cc: linux-hwmon@xxxxxxxxxxxxxxx <linux-hwmon@xxxxxxxxxxxxxxx>; Peter Rosin <peda@xxxxxxxxxx>; Jonathan Cameron <jic23@xxxxxxxxx>; linux-iio@xxxxxxxxxxxxxxx <linux-iio@xxxxxxxxxxxxxxx>
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?



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux