[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZOdFyKHBc6BcOgZw@smile.fi.intel.com>
Date: Thu, 24 Aug 2023 14:58:00 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Mehdi Djait <mehdi.djait.k@...il.com>
Cc: jic23@...nel.org, mazziesaccount@...il.com,
krzysztof.kozlowski+dt@...aro.org, robh+dt@...nel.org,
lars@...afoo.de, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to
retrieve number of bytes in buffer
On Wed, Aug 23, 2023 at 11:16:40PM +0200, 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
...
> + int ret, fifo_bytes;
> +
> + ret = regmap_read(data->regmap, KX022A_REG_BUF_STATUS_1, &fifo_bytes);
> + if (ret) {
> + dev_err(data->dev, "Error reading buffer status\n");
> + return ret;
> + }
> +
> + if (fifo_bytes == KX022A_FIFO_FULL_VALUE)
> + return KX022A_FIFO_MAX_BYTES;
> +
> + return fifo_bytes;
This will be called each time ->get_fifo_bytes() called.
Do you expect the fifo_bytes to be changed over times?
Shouldn't we simply cache the value?
...
> + fifo_bytes = data->chip_info->get_fifo_bytes(data);
>
Now this blank line becomes redundant.
> if (fifo_bytes % KX022A_FIFO_SAMPLES_SIZE_BYTES)
> dev_warn(data->dev, "Bad FIFO alignment. Data may be corrupt\n");
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists