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

From: Andy Shevchenko
Date: Mon Jun 12 2023 - 11:56:48 EST


On Mon, Jun 12, 2023 at 04:22:09PM +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

...

> +static int kx022a_get_fifo_bytes(struct kx022a_data *data)
> +{
> + 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)

> + fifo_bytes = KX022A_FIFO_MAX_BYTES;

You can return this constant directly.

> + return fifo_bytes;
> +}

--
With Best Regards,
Andy Shevchenko