From: Mehdi Djait <mehdi.djait.k@gmail.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: jic23@kernel.org, krzysztof.kozlowski+dt@linaro.org,
andriy.shevchenko@linux.intel.com, robh+dt@kernel.org,
lars@metafoo.de, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Date: Tue, 25 Apr 2023 09:26:03 +0200 [thread overview]
Message-ID: <ZEeAi/wSpmZXpzg6@carbian> (raw)
In-Reply-To: <b0f894fa-a216-aead-a5a4-1844292acad9@gmail.com>
Hi Matti,
On Tue, Apr 25, 2023 at 10:07:54AM +0300, Matti Vaittinen wrote:
> On 4/25/23 01:22, Mehdi Djait wrote:
> > Since Kionix accelerometers use various numbers of bits to report data, a
> > device-specific function is required.
> > Implement the function as a callback in the device-specific chip_info structure
> >
> > Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
> > ---
> > v3:
> > - fixed the warning of the kernel test robot in kx132_get_fifo_bytes
>
> Do you mean kx022a_get_fifo_bytes? (I guess this won't go to commit logs so
> no need to respin for this).
>
> > (invalid assignment: &=, left side has type restricted __le16
> > right side has type unsigned short)
> >
> > v2:
> > - mentioned the kx132-1211 in the Kconfig
> > - added a kx132-specific get_fifo_bytes function
> > - changed the device name from "kx132" to "kx132-1211
> >
> > drivers/iio/accel/kionix-kx022a.c | 30 ++++++++++++++++++++----------
> > drivers/iio/accel/kionix-kx022a.h | 4 ++++
> > 2 files changed, 24 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
> > index 66da3c8c3fd0..4a31d17c1f22 100644
> > --- a/drivers/iio/accel/kionix-kx022a.c
> > +++ b/drivers/iio/accel/kionix-kx022a.c
> > @@ -595,11 +595,28 @@ static int kx022a_drop_fifo_contents(struct kx022a_data *data)
> > return regmap_write(data->regmap, data->chip_info->buf_clear, 0x0);
> > }
> > +static int kx022a_get_fifo_bytes(struct kx022a_data *data)
> > +{
> > + struct device *dev = regmap_get_device(data->regmap);
> > + int ret, fifo_bytes;
> > +
> > + ret = regmap_read(data->regmap, KX022A_REG_BUF_STATUS_1, &fifo_bytes);
> > + if (ret) {
> > + dev_err(dev, "Error reading buffer status\n");
> > + return ret;
> > + }
> > +
> > + /* Let's not overflow if we for some reason get bogus value from i2c */
>
> This comment would need fixing. I guess this is my bad - this comment goes
> back to first internal draft datasheets where the fifo lenght was said to be
> shorter than 255 bytes...
>
> > + if (fifo_bytes == KX022A_FIFO_FULL_VALUE)
> > + fifo_bytes = KX022A_FIFO_MAX_BYTES;
>
> ...Currently the fifo size (KX022A_FIFO_MAX_BYTES) is 258 bytes and
> KX022A_FIFO_FULL_VALUE is 255 (8-bit register) - meaning that no matter what
> noise there is in the I2C line, we won't overflow the buffer. This check is
> here to handle the 'quirk' where full 258 bytes of FIFO data is advertised
> by register max value (255).
>
> It wouldn't be fair to require fixing this in context of this change - but I
> guess I can ask you to please update the comment if you happen to re-work
> this file ;)
I will take care of the comment if there is a v4
--
Kind Regards
Mehdi Djait
next prev parent reply other threads:[~2023-04-25 7:26 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 22:22 [PATCH v3 0/7] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer Mehdi Djait
2023-04-24 22:22 ` [PATCH v3 1/7] dt-bindings: iio: Add " Mehdi Djait
2023-04-24 22:22 ` [PATCH v3 2/7] iio: accel: kionix-kx022a: Remove blank lines Mehdi Djait
2023-04-25 5:26 ` Matti Vaittinen
2023-04-24 22:22 ` [PATCH v3 3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility Mehdi Djait
2023-04-24 22:22 ` [PATCH v3 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table Mehdi Djait
2023-04-25 5:31 ` Matti Vaittinen
2023-05-01 14:42 ` Jonathan Cameron
2023-04-25 13:40 ` Andy Shevchenko
2023-04-29 13:10 ` Mehdi Djait
2023-04-24 22:22 ` [PATCH v3 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure Mehdi Djait
2023-04-25 6:50 ` Matti Vaittinen
2023-04-25 7:24 ` Mehdi Djait
2023-04-25 8:12 ` Matti Vaittinen
2023-04-29 12:59 ` Mehdi Djait
2023-04-29 13:56 ` Matti Vaittinen
2023-05-01 14:50 ` Jonathan Cameron
2023-05-07 20:45 ` Mehdi Djait
2023-05-08 6:12 ` Matti Vaittinen
2023-04-25 15:57 ` Andi Shyti
2023-04-29 13:07 ` Mehdi Djait
2023-04-30 17:49 ` Jonathan Cameron
2023-05-02 19:41 ` Andy Shevchenko
2023-05-05 18:12 ` Mehdi Djait
2023-04-24 22:22 ` [PATCH v3 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer Mehdi Djait
2023-04-25 7:07 ` Matti Vaittinen
2023-04-25 7:26 ` Mehdi Djait [this message]
2023-04-24 22:22 ` [PATCH v3 7/7] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer Mehdi Djait
2023-04-25 8:06 ` Matti Vaittinen
2023-05-01 15:04 ` Jonathan Cameron
2023-05-01 14:56 ` Jonathan Cameron
2023-05-05 18:11 ` Mehdi Djait
2023-05-06 16:46 ` Jonathan Cameron
2023-05-07 14:56 ` Mehdi Djait
2023-05-13 17:13 ` 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=ZEeAi/wSpmZXpzg6@carbian \
--to=mehdi.djait.k@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=robh+dt@kernel.org \
/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