* [PATCH] iio: Fix two mpl3115 issues in measurement conversion
@ 2014-05-20 7:36 Peter Meerwald
2014-05-24 10:47 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Peter Meerwald @ 2014-05-20 7:36 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, Peter Meerwald
(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>
---
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,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iio: Fix two mpl3115 issues in measurement conversion
2014-05-20 7:36 [PATCH] iio: Fix two mpl3115 issues in measurement conversion Peter Meerwald
@ 2014-05-24 10:47 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-05-24 10:47 UTC (permalink / raw)
To: Peter Meerwald, linux-iio
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,
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-24 10:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 7:36 [PATCH] iio: Fix two mpl3115 issues in measurement conversion Peter Meerwald
2014-05-24 10:47 ` Jonathan Cameron
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).