All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 0001-xilinx-xadc-core-Fix-voltage-offset.patch
@ 2014-11-06 15:33 Fabien Proriol
  2014-11-06 15:44 ` Lars-Peter Clausen
  0 siblings, 1 reply; 11+ messages in thread
From: Fabien Proriol @ 2014-11-06 15:33 UTC (permalink / raw)
  To: Jonathan Cameron, Michal Simek
  Cc: Lars-Peter Clausen, linux-iio@vger.kernel.org

 From 3f57e39e3c69476513c00cd5ec45703f58334972 Mon Sep 17 00:00:00 2001
From: Fabien Proriol <fabien.proriol@jdsu.com>
Date: Tue, 4 Nov 2014 17:05:59 +0100
Subject: [PATCH] xilinx-xadc-core: Fix voltage offset

When xilinx-xadc is used with hwmon driver to read voltage, offset used 
for temperature is always apply.
This patch change the return for IIO_CHAN_INFO_OFFSET to -EINVAL except 
for temperature to avoid offset.

Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com>
---
  drivers/iio/adc/xilinx-xadc-core.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/xilinx-xadc-core.c 
b/drivers/iio/adc/xilinx-xadc-core.c
index 41d3a5e..6064d26 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -877,9 +877,14 @@ static int xadc_read_raw(struct iio_dev *indio_dev,
                         return -EINVAL;
                 }
         case IIO_CHAN_INFO_OFFSET:
-               /* Only the temperature channel has an offset */
-               *val = -((273150 << 12) / 503975);
-               return IIO_VAL_INT;
+               switch (chan->type) {
+               case IIO_TEMP:
+                       /* Only the temperature channel has an offset */
+                       *val = -((273150 << 12) / 503975);
+                       return IIO_VAL_INT;
+               default:
+                       return -EINVAL;
+               }
         case IIO_CHAN_INFO_SAMP_FREQ:
                 ret = xadc_read_adc_reg(xadc, XADC_REG_CONF2, &val16);
                 if (ret)
-- 
2.0.4

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

end of thread, other threads:[~2015-01-01 12:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 15:33 [PATCH] 0001-xilinx-xadc-core-Fix-voltage-offset.patch Fabien Proriol
2014-11-06 15:44 ` Lars-Peter Clausen
2014-11-06 16:18   ` Fabien Proriol
2014-11-06 16:25     ` Lars-Peter Clausen
2014-11-16 20:29       ` Jonathan Cameron
2014-11-16 20:35         ` Lars-Peter Clausen
     [not found]       ` <545BA802.5090206@jdsu.com>
     [not found]         ` <54690AE5.4050900@metafoo.de>
2014-11-17  8:53           ` Fabien Proriol
2014-11-17  8:55             ` Lars-Peter Clausen
2014-11-22 11:44               ` Jonathan Cameron
2014-12-05 16:12                 ` Fabien Proriol
2015-01-01 12:50                   ` Jonathan Cameron

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.