linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes
@ 2011-12-14 12:12 michael.hennerich
  2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: michael.hennerich @ 2011-12-14 12:12 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, device-drivers-devel, drivers, Michael Hennerich

From: Michael Hennerich <michael.hennerich@analog.com>

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>
---
 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 e832aea..9d33628 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,
 {
 	int ret;
 	s16 t;
-	u16 ut;
+
 	switch (mask) {
 	case 0:
 		switch (chan->type) {
@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
 			break;
 		case IIO_TEMP:
 			ret = adxrs450_spi_read_reg_16(indio_dev,
-						       ADXRS450_TEMP1, &ut);
+						       ADXRS450_TEMP1, &t);
 			if (ret)
 				break;
-			*val = ut;
+			*val = (t >> 6) + 225;
 			ret = IIO_VAL_INT;
 			break;
 		default:
@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
 			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:
 		ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
 		if (ret)
@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_Z,
 		.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,
 		.indexed = 1,
 		.channel = 0,
+		.info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
 	}
 };
 
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-14 17:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-14 12:12 [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes michael.hennerich
2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich
2011-12-14 14:17   ` J.I. Cameron
2011-12-14 12:12 ` [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope michael.hennerich
2011-12-14 14:14   ` J.I. Cameron
2011-12-14 15:06     ` Hennerich, Michael
2011-12-14 17:07       ` Jonathan Cameron
2011-12-14 14:17 ` [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes J.I. 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).