Commit 90b9b227 authored by Michael Hennerich's avatar Michael Hennerich Committed by Greg Kroah-Hartman

iio: gyro: ADXRS450: Add missing scale attributes

Add missing scale attributes.
Temperature data is presented as 10-bit, twos complement number.
Therefore use singed and shift accordingly.
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Acked-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 70fe742c
...@@ -263,7 +263,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, ...@@ -263,7 +263,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
{ {
int ret; int ret;
s16 t; s16 t;
u16 ut;
switch (mask) { switch (mask) {
case 0: case 0:
switch (chan->type) { switch (chan->type) {
...@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, ...@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
break; break;
case IIO_TEMP: case IIO_TEMP:
ret = adxrs450_spi_read_reg_16(indio_dev, ret = adxrs450_spi_read_reg_16(indio_dev,
ADXRS450_TEMP1, &ut); ADXRS450_TEMP1, &t);
if (ret) if (ret)
break; break;
*val = ut; *val = (t >> 6) + 225;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
default: default:
...@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, ...@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
break; break;
} }
break; break;
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
*val = 0;
*val2 = 218166;
return IIO_VAL_INT_PLUS_NANO;
case IIO_TEMP:
*val = 200;
*val2 = 0;
return IIO_VAL_INT;
default:
return -EINVAL;
}
break;
case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW:
ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
if (ret) if (ret)
...@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[] = { ...@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[] = {
.modified = 1, .modified = 1,
.channel2 = IIO_MOD_Z, .channel2 = IIO_MOD_Z,
.info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, { }, {
.type = IIO_TEMP, .type = IIO_TEMP,
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment