summaryrefslogtreecommitdiff
path: root/drivers/iio/accel/mma8452.c
diff options
context:
space:
mode:
authorMartin Fuzzey <mfuzzey@parkeon.com>2014-11-07 13:54:00 +0000
committerJonathan Cameron <jic23@kernel.org>2014-07-12 13:18:55 +0100
commit71702e6e52c8312f4c6797a9787d0f8b5656156f (patch)
tree21bf3ee4d0166292776d5097f10794d138aa8248 /drivers/iio/accel/mma8452.c
parent78b3321610bf920d7fceb1a0236faa881be0bcf3 (diff)
iio: mma8452: Use correct acceleration units.iio-fixes-for-3.16d
The userspace interface for acceleration sensors is documented as using m/s^2 units [Documentation/ABI/testing/sysfs-bus-iio] The fullscale raw value for the mma8452 (-2048) corresponds to -2G, -4G or -8G depending on the seleted mode. The scale table was converting to G rather than m/s^2. Change the scaling table to match the documented interface. Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/iio/accel/mma8452.c')
-rw-r--r--drivers/iio/accel/mma8452.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 17aeea170566..2a5fa9a436e5 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -111,8 +111,14 @@ static const int mma8452_samp_freq[8][2] = {
{6, 250000}, {1, 560000}
};
+/*
+ * Hardware has fullscale of -2G, -4G, -8G corresponding to raw value -2048
+ * The userspace interface uses m/s^2 and we declare micro units
+ * So scale factor is given by:
+ * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
+ */
static const int mma8452_scales[3][2] = {
- {0, 977}, {0, 1953}, {0, 3906}
+ {0, 9577}, {0, 19154}, {0, 38307}
};
static ssize_t mma8452_show_samp_freq_avail(struct device *dev,