Re: [PATCH v4 2/6] iio: backend: update iio_backend_oversampling_ratio_set
From: Nuno Sá
Date: Mon May 26 2025 - 05:54:45 EST
On Mon, 2025-05-19 at 17:02 +0300, Pop Ioan Daniel wrote:
> Add chan parameter to iio_backed_oversampling_ration_set() to allow
> for contexts where the channel must be specified. Modify all
> existing users.
>
> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@xxxxxxxxxx>
> ---
With the change requested by David in the following patch:
Reviewed-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
> changes in v4:
> - pass 0 in the list of parameters instead of chan
> drivers/iio/adc/ad4851.c | 4 ++--
> drivers/iio/industrialio-backend.c | 3 ++-
> include/linux/iio/backend.h | 3 ++-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c
> index 12f90aa3a156..1f975858c496 100644
> --- a/drivers/iio/adc/ad4851.c
> +++ b/drivers/iio/adc/ad4851.c
> @@ -319,8 +319,8 @@ static int ad4851_set_oversampling_ratio(struct iio_dev
> *indio_dev,
> if (ret)
> return ret;
> }
> -
> - ret = iio_backend_oversampling_ratio_set(st->back, osr);
> + /* Channel is ignored by the backend being used here */
> + ret = iio_backend_oversampling_ratio_set(st->back, 0, osr);
> if (ret)
> return ret;
>
> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-
> backend.c
> index c1eb9ef9db08..a4e3e54fecb1 100644
> --- a/drivers/iio/industrialio-backend.c
> +++ b/drivers/iio/industrialio-backend.c
> @@ -720,9 +720,10 @@ EXPORT_SYMBOL_NS_GPL(iio_backend_data_size_set,
> "IIO_BACKEND");
> * 0 on success, negative error number on failure.
> */
> int iio_backend_oversampling_ratio_set(struct iio_backend *back,
> + unsigned int chan,
> unsigned int ratio)
> {
> - return iio_backend_op_call(back, oversampling_ratio_set, ratio);
> + return iio_backend_op_call(back, oversampling_ratio_set, chan,
> ratio);
> }
> EXPORT_SYMBOL_NS_GPL(iio_backend_oversampling_ratio_set, "IIO_BACKEND");
>
> diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
> index e59d909cb659..dbf4e4a5f4b1 100644
> --- a/include/linux/iio/backend.h
> +++ b/include/linux/iio/backend.h
> @@ -144,7 +144,7 @@ struct iio_backend_ops {
> enum iio_backend_interface_type *type);
> int (*data_size_set)(struct iio_backend *back, unsigned int size);
> int (*oversampling_ratio_set)(struct iio_backend *back,
> - unsigned int ratio);
> + unsigned int chan, unsigned int ratio);
> int (*read_raw)(struct iio_backend *back,
> struct iio_chan_spec const *chan, int *val, int
> *val2,
> long mask);
> @@ -209,6 +209,7 @@ int iio_backend_interface_type_get(struct iio_backend
> *back,
> enum iio_backend_interface_type *type);
> int iio_backend_data_size_set(struct iio_backend *back, unsigned int size);
> int iio_backend_oversampling_ratio_set(struct iio_backend *back,
> + unsigned int chan,
> unsigned int ratio);
> int iio_backend_read_raw(struct iio_backend *back,
> struct iio_chan_spec const *chan, int *val, int
> *val2,