diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2011-12-14 14:25:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-12-16 13:55:00 -0500 |
commit | 90b9b2276bdc1a3cdff881a71a652683f6a5d58f (patch) | |
tree | a458fc27322ccb1e25b99f86c1f21aff3f08e809 /drivers | |
parent | 70fe742c94d4d5e7763c3f864f13c0e907ac3d48 (diff) |
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: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/gyro/adxrs450_core.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index e832aeabd879..9d3362880d68 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c | |||
@@ -263,7 +263,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, | |||
263 | { | 263 | { |
264 | int ret; | 264 | int ret; |
265 | s16 t; | 265 | s16 t; |
266 | u16 ut; | 266 | |
267 | switch (mask) { | 267 | switch (mask) { |
268 | case 0: | 268 | case 0: |
269 | switch (chan->type) { | 269 | switch (chan->type) { |
@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, | |||
276 | break; | 276 | break; |
277 | case IIO_TEMP: | 277 | case IIO_TEMP: |
278 | ret = adxrs450_spi_read_reg_16(indio_dev, | 278 | ret = adxrs450_spi_read_reg_16(indio_dev, |
279 | ADXRS450_TEMP1, &ut); | 279 | ADXRS450_TEMP1, &t); |
280 | if (ret) | 280 | if (ret) |
281 | break; | 281 | break; |
282 | *val = ut; | 282 | *val = (t >> 6) + 225; |
283 | ret = IIO_VAL_INT; | 283 | ret = IIO_VAL_INT; |
284 | break; | 284 | break; |
285 | default: | 285 | default: |
@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, | |||
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | case IIO_CHAN_INFO_SCALE: | ||
291 | switch (chan->type) { | ||
292 | case IIO_ANGL_VEL: | ||
293 | *val = 0; | ||
294 | *val2 = 218166; | ||
295 | return IIO_VAL_INT_PLUS_NANO; | ||
296 | case IIO_TEMP: | ||
297 | *val = 200; | ||
298 | *val2 = 0; | ||
299 | return IIO_VAL_INT; | ||
300 | default: | ||
301 | return -EINVAL; | ||
302 | } | ||
303 | break; | ||
290 | case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: | 304 | case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: |
291 | ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); | 305 | ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); |
292 | if (ret) | 306 | if (ret) |
@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[] = { | |||
308 | .modified = 1, | 322 | .modified = 1, |
309 | .channel2 = IIO_MOD_Z, | 323 | .channel2 = IIO_MOD_Z, |
310 | .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | | 324 | .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | |
311 | IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, | 325 | IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | |
326 | IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | ||
312 | }, { | 327 | }, { |
313 | .type = IIO_TEMP, | 328 | .type = IIO_TEMP, |
314 | .indexed = 1, | 329 | .indexed = 1, |
315 | .channel = 0, | 330 | .channel = 0, |
331 | .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, | ||
316 | } | 332 | } |
317 | }; | 333 | }; |
318 | 334 | ||