From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jagath Jog J <jagathjog1996@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Mehdi Djait <mehdi.djait.k@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: kx022a: Fix acceleration value scaling
Date: Fri, 20 Oct 2023 15:09:14 +0300 [thread overview]
Message-ID: <c623b6ff-6d6c-4351-b828-4ed4663f9de9@gmail.com> (raw)
In-Reply-To: <CAM+2Eu+ndzS9NLvsZaX_=YTHb_+t4cE5GjQevJ1Lgc2EBO20rA@mail.gmail.com>
On 10/19/23 21:21, Jagath Jog J wrote:
> Hi Matti,
>
> On Thu, Oct 19, 2023 at 6:54 PM Matti Vaittinen
> <mazziesaccount@gmail.com> wrote:
>>
>> The IIO ABI mandates acceleration values from accelerometer to be
>> emitted in m/s^2. The KX022A was emitting values in micro m/s^2.
>>
>> Fix driver to report the correct scale values.
>>
>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>> Reported-by: Jagath Jog J <jagathjog1996@gmail.com>
>> Fixes: 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer")
>>
>> ---
>> The fix is somewhat crude and just crops the last 3 digits (rounds) of the
>> scale while using IIO_VAL_INT_PLUS_NANO. I played with a thought of using
>> IIO_VAL_FRACTIONAL, which could have modelled the computation
>> G_range * g * scaling / (2^16 * scaling) - where scaling 10000 would
>> have allowed using g value 980665.
>>
>> This would have worked fine for reporting scale and available scales -
>> but would be somewhat tricky when converting the user-supplied scale to
>> register values in write_raw().
>>
>> Well, the g varies from 9.832 (poles) to 9.780 (equator) according to
>> some website - no proper source check done but this sounds about right -
>> so maybe the loss of accuracy is acceptable.
>>
>> I did only very quick testing on KX022A and iio_generic_buffer. After
>> the patch the values seemed to be correct order of magnitude. Further
>> testing is appreciated :)
>
> Values are correct with this change, Thank you for fixing.
> Tested-by: Jagath Jog J <jagathjog1996@gmail.com>
Thanks a ton for testing! May I ask which component did you use (or did
you just use some 'simulated' regster values?)
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-10-20 12:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-19 13:23 [PATCH] iio: kx022a: Fix acceleration value scaling Matti Vaittinen
2023-10-19 18:21 ` Jagath Jog J
2023-10-20 12:09 ` Matti Vaittinen [this message]
2023-10-20 16:48 ` Jagath Jog J
2023-10-23 6:24 ` Matti Vaittinen
2023-10-21 15:51 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c623b6ff-6d6c-4351-b828-4ed4663f9de9@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=jagathjog1996@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mehdi.djait.k@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox