iio: mma8452: Use correct acceleration units.
PATCH 1/1 iio: mma8452: Use correct acceleration units.
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.
--- drivers/iio/accel/mma8452.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/accel/mma8452.c +6 -1
@@ -111,8 +111,13 @@ 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,
Quoted 19 lines · Martin Fuzzey
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 <[email protected]>--- drivers/iio/accel/mma8452.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/iio/accel/mma8452.c +0
-0
drivers/iio/accel/mma8452.c static const int mma8452_samp_freq[8][2] = { · line 113
Quoted 3 lines
drivers/iio/accel/mma8452.c +0
-0@@ -111,8 +111,13 @@ static const int mma8452_samp_freq[8][2] = { {6, 250000}, {1, 560000} };
The first line of the comment should just contain /*
Quoted 17 lines
drivers/iio/accel/mma8452.c +6
-2+/* 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, --To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 11 lines · Hartmut Knaack
Quoted 10 lines · Martin Fuzzey
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 <[email protected]>
Fixed up and applied to the fixes-togreg branch of iio.git. Also marked for stable.
Thanks,
J
Quoted 31 lines
drivers/iio/accel/mma8452.c static const int mma8452_samp_freq[8][2] = { · line 113
Quoted 12 lines
--- drivers/iio/accel/mma8452.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/iio/accel/mma8452.c +0
-0@@ -111,8 +111,13 @@ static const int mma8452_samp_freq[8][2] = { {6, 250000}, {1, 560000} };The first line of the comment should just contain /*
Quoted 17 lines
drivers/iio/accel/mma8452.c +6
-2+/* 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, --To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html