All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: ntc: Don't assume a 12 bit ADC
@ 2015-05-26 20:41 Chris Lesiak
  2015-05-26 23:00 ` Guenter Roeck
  2015-05-27 14:36 ` Chris Lesiak
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Lesiak @ 2015-05-26 20:41 UTC (permalink / raw)
  To: lm-sensors

The function ntc_adc_iio_read was using iio_read_channel_raw and
converting to microVolts using the assumption of a 12 bit ADC.  If a
converter with different precision was used, the result was in error.

Instead, use iio_read_channel_processed, which does the conversion to
microVolts itself.

Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
---
 drivers/hwmon/ntc_thermistor.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 6880011..0d3a686 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -190,20 +190,15 @@ struct ntc_data {
 static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
 {
 	struct iio_channel *channel = pdata->chan;
-	s64 result;
 	int val, ret;
 
-	ret = iio_read_channel_raw(channel, &val);
+	ret = iio_read_channel_processed(channel, &val);
 	if (ret < 0) {
 		pr_err("read channel() error: %d\n", ret);
 		return ret;
 	}
 
-	/* unit: mV */
-	result = pdata->pullup_uv * (s64) val;
-	result >>= 12;
-
-	return (int)result;
+	return val;
 }
 
 static const struct of_device_id ntc_match[] = {
-- 
1.9.3


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

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

end of thread, other threads:[~2015-05-27 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 20:41 [lm-sensors] [PATCH] hwmon: ntc: Don't assume a 12 bit ADC Chris Lesiak
2015-05-26 23:00 ` Guenter Roeck
2015-05-27 14:36 ` Chris Lesiak

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.