linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald <pmeerw@pmeerw.net>, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: Fix two mpl3115 issues in measurement conversion
Date: Sat, 24 May 2014 11:47:24 +0100	[thread overview]
Message-ID: <538078BC.9090409@kernel.org> (raw)
In-Reply-To: <1400571365-23380-1-git-send-email-pmeerw@pmeerw.net>

On 20/05/14 08:36, Peter Meerwald wrote:
> (i) pressure is 20-bit unsigned, not signed; the buffer description
> is incorrect; for raw reads, this is just cosmetic
>
> (ii) temperature is 12-bit signed, not 16-bit; this affects
> readout of temperatures below zero as the sign bit is incorrectly
> processed
>
> reported via private mail
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
> Reported-by: Robert Deliën <robert@delien.nl>
Given how late we are in the current cycle I've applied this to the togreg
branch of iio.git (for the next merge window) but also marked it for stable.

Thanks,

Jonathan
> ---
>   drivers/iio/pressure/mpl3115.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
> index ba6d0c5..01b2e0b 100644
> --- a/drivers/iio/pressure/mpl3115.c
> +++ b/drivers/iio/pressure/mpl3115.c
> @@ -98,7 +98,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
>   			mutex_unlock(&data->lock);
>   			if (ret < 0)
>   				return ret;
> -			*val = sign_extend32(be32_to_cpu(tmp) >> 12, 23);
> +			*val = be32_to_cpu(tmp) >> 12;
>   			return IIO_VAL_INT;
>   		case IIO_TEMP: /* in 0.0625 celsius / LSB */
>   			mutex_lock(&data->lock);
> @@ -112,7 +112,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
>   			mutex_unlock(&data->lock);
>   			if (ret < 0)
>   				return ret;
> -			*val = sign_extend32(be32_to_cpu(tmp) >> 20, 15);
> +			*val = sign_extend32(be32_to_cpu(tmp) >> 20, 11);
>   			return IIO_VAL_INT;
>   		default:
>   			return -EINVAL;
> @@ -185,7 +185,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
>   			BIT(IIO_CHAN_INFO_SCALE),
>   		.scan_index = 0,
>   		.scan_type = {
> -			.sign = 's',
> +			.sign = 'u',
>   			.realbits = 20,
>   			.storagebits = 32,
>   			.shift = 12,
>


      reply	other threads:[~2014-05-24 10:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20  7:36 [PATCH] iio: Fix two mpl3115 issues in measurement conversion Peter Meerwald
2014-05-24 10:47 ` Jonathan Cameron [this message]

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=538078BC.9090409@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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).