From: Joshua Lamorie <joshua.lamorie@xiphos.com>
To: jic23@kernel.org
Cc: michal.simek@xilinx.com, lars@metafoo.de,
linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, soren.brinkmann@xilinx.com,
Joshua Lamorie <joshua.lamorie@xiphos.com>
Subject: [PATCH] iio:xilinx-xadc:xadc_read_raw INFO_OFFSET
Date: Fri, 7 Nov 2014 14:11:56 -0500 [thread overview]
Message-ID: <1415387516-15051-1-git-send-email-joshua.lamorie@xiphos.com> (raw)
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
next reply other threads:[~2014-11-07 19:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 19:11 Joshua Lamorie [this message]
2014-11-07 19:34 ` Lars-Peter Clausen
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415387516-15051-1-git-send-email-joshua.lamorie@xiphos.com \
--to=joshua.lamorie@xiphos.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=soren.brinkmann@xilinx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®