lkml.org 
[lkml]   [2023]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
From
On 8/24/23 14:58, Andy Shevchenko wrote:
> 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?

I think this value tells how many samples there currently is in the
FIFO. Caching it does not sound meaningful unless I am missing something.

Yours,
-- Matti

--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~

\
 
 \ /
  Last update: 2023-08-24 14:54    [W:0.086 / U:2.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site