lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c623b6ff-6d6c-4351-b828-4ed4663f9de9@gmail.com>
Date:   Fri, 20 Oct 2023 15:09:14 +0300
From:   Matti Vaittinen <mazziesaccount@...il.com>
To:     Jagath Jog J <jagathjog1996@...il.com>
Cc:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Mehdi Djait <mehdi.djait.k@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: kx022a: Fix acceleration value scaling

On 10/19/23 21:21, Jagath Jog J wrote:
> Hi Matti,
> 
> On Thu, Oct 19, 2023 at 6:54 PM Matti Vaittinen
> <mazziesaccount@...il.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@...il.com>
>> Reported-by: Jagath Jog J <jagathjog1996@...il.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@...il.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! ~~

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ