linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: mma8452: Use correct acceleration units.
@ 2014-07-11 12:54 Martin Fuzzey
  2014-07-12 10:50 ` Hartmut Knaack
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Fuzzey @ 2014-07-11 12:54 UTC (permalink / raw)
  To: linux-iio, Jonathan Cameron

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>
---
 drivers/iio/accel/mma8452.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 17aeea1..61eba5a 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -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,


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

* Re: [PATCH] iio: mma8452: Use correct acceleration units.
  2014-07-11 12:54 [PATCH] iio: mma8452: Use correct acceleration units Martin Fuzzey
@ 2014-07-12 10:50 ` Hartmut Knaack
  2014-07-12 12:19   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Hartmut Knaack @ 2014-07-12 10:50 UTC (permalink / raw)
  To: Martin Fuzzey, linux-iio, Jonathan Cameron

Martin Fuzzey schrieb:
> 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>
> ---
>  drivers/iio/accel/mma8452.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 17aeea1..61eba5a 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -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 /*
> +/* 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


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

* Re: [PATCH] iio: mma8452: Use correct acceleration units.
  2014-07-12 10:50 ` Hartmut Knaack
@ 2014-07-12 12:19   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2014-07-12 12:19 UTC (permalink / raw)
  To: Hartmut Knaack, Martin Fuzzey, linux-iio

On 12/07/14 11:50, Hartmut Knaack wrote:
> Martin Fuzzey schrieb:
>> 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>
Fixed up and applied to the fixes-togreg branch of iio.git.
Also marked for stable.

Thanks,

J
>> ---
>>   drivers/iio/accel/mma8452.c |    7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
>> index 17aeea1..61eba5a 100644
>> --- a/drivers/iio/accel/mma8452.c
>> +++ b/drivers/iio/accel/mma8452.c
>> @@ -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 /*
>> +/* 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 majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 12:54 [PATCH] iio: mma8452: Use correct acceleration units Martin Fuzzey
2014-07-12 10:50 ` Hartmut Knaack
2014-07-12 12:19   ` Jonathan 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).