Re: [PATCH v5 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 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





[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