* [PATCH] iio:xilinx-xadc:xadc_read_raw INFO_OFFSET
@ 2014-11-07 19:11 Joshua Lamorie
2014-11-07 19:34 ` Lars-Peter Clausen
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Lamorie @ 2014-11-07 19:11 UTC (permalink / raw)
To: jic23
Cc: michal.simek, lars, linux-iio, linux-arm-kernel, linux-kernel,
soren.brinkmann, Joshua Lamorie
Added a condition for a read of IIO_CHAN_INFO_OFFSET to
ensure that an offset is only provided for requests for XADC temperature. The
previous assumption was that only requests for temperature would include a
read of CHAN_INFO_OFFSET. However there is no way to restrict this in calling
functions, such as iio_convert_raw_to_processed_unlocked() which is called when
using the XADC as a device for iio_hwmon.
Signed-off-by: Joshua Lamorie <joshua.lamorie@xiphos.com>
---
drivers/iio/adc/xilinx-xadc-core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 23c152e..2c549ab 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -877,9 +877,13 @@ 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;
+ if (chan->type == IIO_TEMP) {
+ /* Only the temperature channel has an offset */
+ *val = -((273150 << 12) / 503975);
+ return IIO_VAL_INT;
+ } else {
+ return -EINVAL;
+ }
case IIO_CHAN_INFO_SAMP_FREQ:
ret = xadc_read_adc_reg(xadc, XADC_REG_CONF2, &val16);
if (ret)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio:xilinx-xadc:xadc_read_raw INFO_OFFSET
2014-11-07 19:11 [PATCH] iio:xilinx-xadc:xadc_read_raw INFO_OFFSET Joshua Lamorie
@ 2014-11-07 19:34 ` Lars-Peter Clausen
0 siblings, 0 replies; 2+ messages in thread
From: Lars-Peter Clausen @ 2014-11-07 19:34 UTC (permalink / raw)
To: Joshua Lamorie
Cc: Jonathan Cameron, michal.simek, linux-iio, linux-arm-kernel,
linux-kernel, soren.brinkmann, Fabien Proriol
On 11/07/2014 08:11 PM, Joshua Lamorie wrote:
> Added a condition for a read of IIO_CHAN_INFO_OFFSET to
> ensure that an offset is only provided for requests for XADC temperature. The
> previous assumption was that only requests for temperature would include a
> read of CHAN_INFO_OFFSET. However there is no way to restrict this in calling
> functions, such as iio_convert_raw_to_processed_unlocked() which is called when
> using the XADC as a device for iio_hwmon.
Fabien send pretty much the same patch yesterday. See
http://thread.gmane.org/gmane.linux.kernel.iio/14579
- Lars
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-07 19:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 19:11 [PATCH] iio:xilinx-xadc:xadc_read_raw INFO_OFFSET Joshua Lamorie
2014-11-07 19:34 ` Lars-Peter Clausen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).