From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-100.synserver.de ([212.40.185.100]:1030 "EHLO smtp-out-100.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019Ab2JOJeh (ORCPT ); Mon, 15 Oct 2012 05:34:37 -0400 From: Lars-Peter Clausen To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, drivers@analog.com, Lars-Peter Clausen Subject: [PATCH 06/11] staging:iio: Fix adis16220 channel offsets and scales Date: Mon, 15 Oct 2012 11:35:29 +0200 Message-Id: <1350293734-21951-6-git-send-email-lars@metafoo.de> In-Reply-To: <1350293734-21951-1-git-send-email-lars@metafoo.de> References: <1350293734-21951-1-git-send-email-lars@metafoo.de> Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org Most of the channel offsets and scales in the adis16220 are incorrect: * Temperature scale is off by a factor of 1000 * Voltage scale is off by a factor of 1000 * Acceleration seems to have a typo "187042" since it should be instead of "1887042" * Temperature offset is completely wrong This patch fixes these issues. Signed-off-by: Lars-Peter Clausen --- drivers/staging/iio/accel/adis16220_core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index c755089..eaadd9d 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -486,7 +486,7 @@ static int adis16220_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_OFFSET: if (chan->type == IIO_TEMP) { - *val = 25; + *val = 25000 / -470 - 1278; /* 25 C = 1278 */ return IIO_VAL_INT; } addrind = 1; @@ -495,19 +495,22 @@ static int adis16220_read_raw(struct iio_dev *indio_dev, addrind = 2; break; case IIO_CHAN_INFO_SCALE: - *val = 0; switch (chan->type) { case IIO_TEMP: - *val2 = -470000; + *val = -470; /* -0.47 C */ + *val2 = 0; return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: - *val2 = 1887042; + *val2 = IIO_G_TO_M_S_2(19073); /* 19.073 g */ return IIO_VAL_INT_PLUS_MICRO; case IIO_VOLTAGE: - if (chan->channel == 0) - *val2 = 0012221; - else /* Should really be dependent on VDD */ - *val2 = 305; + if (chan->channel == 0) { + *val = 1; + *val2 = 220700; /* 1.2207 mV */ + } else { + /* Should really be dependent on VDD */ + *val2 = 305180; /* 305.18 uV */ + } return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL; -- 1.7.10.4