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: <CAM+2Eu+Xp6j1ppLd+zHMTu6jfc6DQKBShfe-nAyokVi0MUmoSA@mail.gmail.com>
Date:   Wed, 18 Oct 2023 01:37:12 +0530
From:   Jagath Jog J <jagathjog1996@...il.com>
To:     Matti Vaittinen <mazziesaccount@...il.com>
Cc:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Dmitry Rokosov <DDRokosov@...rdevices.ru>,
        Cosmin Tanislav <demonsingur@...il.com>,
        linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/3] iio: accel: Support Kionix/ROHM KX022A accelerometer

Hi Matti,

On Mon, Oct 24, 2022 at 6:10 PM Matti Vaittinen
<mazziesaccount@...il.com> wrote:
>
> KX022A is a 3-axis accelerometer from ROHM/Kionix. The sensor features
> include variable ODRs, I2C and SPI control, FIFO/LIFO with watermark IRQ,
> tap/motion detection, wake-up & back-to-sleep events, four acceleration
> ranges (2, 4, 8 and 16g), and probably some other cool features.

This is a nice driver, and I found it very helpful as a reference.
One question regarding scale please see below.

> + * range is typically +-2G/4G/8G/16G, distributed over the amount of bits.
> + * The scale table can be calculated using
> + *     (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
> + *     => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed
> + *     in low-power mode(?) )
> + *     => +/-2G  => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro)
> + *     => +/-2G  - 598.550415
> + *        +/-4G  - 1197.10083
> + *        +/-8G  - 2394.20166
> + *        +/-16G - 4788.40332
> + */
> +static const int kx022a_scale_table[][2] = {
> +       { 598, 550415 },
> +       { 1197, 100830 },
> +       { 2394, 201660 },
> +       { 4788, 403320 },
> +};

Given that the integer part is non-zero, and
IIO_VAL_INT_PLUS_MICRO is returned for read_scale,
As raw value will never be fractional how does this
correspond to a reading of 9.8 m/s² for the Z-axis?

> +
> +static int kx022a_read_avail(struct iio_dev *indio_dev,
> +                            struct iio_chan_spec const *chan,
> +                            const int **vals, int *type, int *length,
> +                            long mask)
> +{
> +       switch (mask) {
> +       case IIO_CHAN_INFO_SAMP_FREQ:
> +               *vals = (const int *)kx022a_accel_samp_freq_table;
> +               *length = ARRAY_SIZE(kx022a_accel_samp_freq_table) *
> +                         ARRAY_SIZE(kx022a_accel_samp_freq_table[0]);
> +               *type = IIO_VAL_INT_PLUS_MICRO;
> +               return IIO_AVAIL_LIST;
> +       case IIO_CHAN_INFO_SCALE:
> +               *vals = (const int *)kx022a_scale_table;
> +               *length = ARRAY_SIZE(kx022a_scale_table) *
> +                         ARRAY_SIZE(kx022a_scale_table[0]);
> +               *type = IIO_VAL_INT_PLUS_MICRO;
> +               return IIO_AVAIL_LIST;
> +       default:
> +               return -EINVAL;
> +       }
> +}

Regards
Jagath

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ