Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 24, 2023 at 03:52:56PM +0300, Matti Vaittinen wrote:
> On 8/24/23 14:58, Andy Shevchenko wrote:
> > On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:

...

> > > +	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.

I see. I think my confusion can be easily cured by renaming the callback to

	get_amount_bytes_in_fifo()

or

	get_bytes_in_fifo()

or alike.

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux