From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/4] staging:iio:adis16130: Report scale and offset
Date: Tue, 11 Jun 2013 20:34:26 +0100 [thread overview]
Message-ID: <51B77BC2.9090705@kernel.org> (raw)
In-Reply-To: <1370872815-14386-3-git-send-email-lars@metafoo.de>
On 06/10/2013 03:00 PM, Lars-Peter Clausen wrote:
> Report scale and offset for the temperature and voltage channels.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git. Thanks.
> ---
> drivers/staging/iio/gyro/adis16130_core.c | 57 +++++++++++++++++++++++++------
> 1 file changed, 47 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c
> index 2537f59..8979435 100644
> --- a/drivers/staging/iio/gyro/adis16130_core.c
> +++ b/drivers/staging/iio/gyro/adis16130_core.c
> @@ -78,14 +78,47 @@ static int adis16130_read_raw(struct iio_dev *indio_dev,
> int ret;
> u32 temp;
>
> - /* Take the iio_dev status lock */
> - mutex_lock(&indio_dev->mlock);
> - ret = adis16130_spi_read(indio_dev, chan->address, &temp);
> - mutex_unlock(&indio_dev->mlock);
> - if (ret)
> - return ret;
> - *val = temp;
> - return IIO_VAL_INT;
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + /* Take the iio_dev status lock */
> + mutex_lock(&indio_dev->mlock);
> + ret = adis16130_spi_read(indio_dev, chan->address, &temp);
> + mutex_unlock(&indio_dev->mlock);
> + if (ret)
> + return ret;
> + *val = temp;
> + return IIO_VAL_INT;
> + case IIO_CHAN_INFO_SCALE:
> + switch (chan->type) {
> + case IIO_ANGL_VEL:
> + /* 0 degree = 838860, 250 degree = 14260608 */
> + *val = 250;
> + *val2 = 336440817; /* RAD_TO_DEGREE(14260608 - 8388608) */
> + return IIO_VAL_FRACTIONAL;
> + case IIO_TEMP:
> + /* 0C = 8036283, 105C = 9516048 */
> + *val = 105000;
> + *val2 = 9516048 - 8036283;
> + return IIO_VAL_FRACTIONAL;
> + default:
> + return -EINVAL;
> + }
> + break;
> + case IIO_CHAN_INFO_OFFSET:
> + switch (chan->type) {
> + case IIO_ANGL_VEL:
> + *val = -8388608;
> + return IIO_VAL_INT;
> + case IIO_TEMP:
> + *val = -8036283;
> + return IIO_VAL_INT;
> + default:
> + return -EINVAL;
> + }
> + break;
> + }
> +
> + return -EINVAL;
> }
>
> static const struct iio_chan_spec adis16130_channels[] = {
> @@ -93,13 +126,17 @@ static const struct iio_chan_spec adis16130_channels[] = {
> .type = IIO_ANGL_VEL,
> .modified = 1,
> .channel2 = IIO_MOD_Z,
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> + BIT(IIO_CHAN_INFO_SCALE) |
> + BIT(IIO_CHAN_INFO_OFFSET),
> .address = ADIS16130_RATEDATA,
> }, {
> .type = IIO_TEMP,
> .indexed = 1,
> .channel = 0,
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> + BIT(IIO_CHAN_INFO_SCALE) |
> + BIT(IIO_CHAN_INFO_OFFSET),
> .address = ADIS16130_TEMPDATA,
> }
> };
>
next prev parent reply other threads:[~2013-06-11 19:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-10 14:00 [PATCH 1/4] staging:iio:adis16130: Remove unused includes Lars-Peter Clausen
2013-06-10 14:00 ` [PATCH 2/4] staging:iio:adis16130: Fix sample reading Lars-Peter Clausen
2013-06-11 19:33 ` Jonathan Cameron
2013-06-10 14:00 ` [PATCH 3/4] staging:iio:adis16130: Report scale and offset Lars-Peter Clausen
2013-06-11 19:34 ` Jonathan Cameron [this message]
2013-06-10 14:00 ` [PATCH 4/4] staging:iio:adis16130: Move out of staging Lars-Peter Clausen
2013-06-11 19:35 ` Jonathan Cameron
2013-06-11 19:32 ` [PATCH 1/4] staging:iio:adis16130: Remove unused includes Jonathan Cameron
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=51B77BC2.9090705@kernel.org \
--to=jic23@kernel.org \
--cc=jic23@cam.ac.uk \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).