In the function iio_backend_oversampling_ratio_set the chan parameter
was added. The function can be used in contexts where the channel
must be specified. All affected files have been modified.
Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
---
changes in v3:
- fix ad4851_set_oversampling_ratio function channel error
drivers/iio/adc/ad4851.c | 6 +++---
drivers/iio/adc/adi-axi-adc.c | 3 ++-
drivers/iio/industrialio-backend.c | 3 ++-
include/linux/iio/backend.h | 3 ++-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c
index 98ebc853db79..fccfca256670 100644
--- a/drivers/iio/adc/ad4851.c
+++ b/drivers/iio/adc/ad4851.c
@@ -294,7 +294,7 @@ static int ad4851_scale_fill(struct iio_dev *indio_dev)
}
static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
+ unsigned int chan,
unsigned int osr)
{
struct ad4851_state *st = iio_priv(indio_dev);
@@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
return ret;
}
- ret = iio_backend_oversampling_ratio_set(st->back, osr);
+ ret = iio_backend_oversampling_ratio_set(st->back, chan, osr);
if (ret)
return ret;
@@ -831,7 +831,7 @@ static int ad4851_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_CALIBBIAS:
return ad4851_set_calibbias(st, chan->channel, val);
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
- return ad4851_set_oversampling_ratio(indio_dev, chan, val);
+ return ad4851_set_oversampling_ratio(indio_dev, chan->channel, val);
default:
return -EINVAL;
}
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 4116c44197b8..9e8c30230791 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -381,7 +381,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_backend *back,
}
static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back,
- unsigned int ratio)
+ unsigned int chan,
+ unsigned int ratio)
{
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
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,
--
2.34.1
On 5/16/25 5:58 AM, Pop Ioan Daniel wrote:
> In the function iio_backend_oversampling_ratio_set the chan parameter
> was added. The function can be used in contexts where the channel
> must be specified. All affected files have been modified.
>
> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
> ---
> changes in v3:
> - fix ad4851_set_oversampling_ratio function channel error
> drivers/iio/adc/ad4851.c | 6 +++---
> drivers/iio/adc/adi-axi-adc.c | 3 ++-
> drivers/iio/industrialio-backend.c | 3 ++-
> include/linux/iio/backend.h | 3 ++-
> 4 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c
> index 98ebc853db79..fccfca256670 100644
> --- a/drivers/iio/adc/ad4851.c
> +++ b/drivers/iio/adc/ad4851.c
> @@ -294,7 +294,7 @@ static int ad4851_scale_fill(struct iio_dev *indio_dev)
> }
>
> static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
> - const struct iio_chan_spec *chan,
> + unsigned int chan,
I think passing the channel here is misleading since this is setting the
oversampling ratio for all channels, not just the one specified.
I would suggest to make a separate patch that removes the unused
const struct iio_chan_spec *chan parameter first.
> unsigned int osr)
> {
> struct ad4851_state *st = iio_priv(indio_dev);
> @@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
> return ret;
> }
>
> - ret = iio_backend_oversampling_ratio_set(st->back, osr);
> + ret = iio_backend_oversampling_ratio_set(st->back, chan, osr);
Then in this patch, just pass 0 here instead of chan with a comment that
the channel is ignored by the backend being used here.
> if (ret)
> return ret;
>
On Fri, 16 May 2025 10:06:18 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 5/16/25 5:58 AM, Pop Ioan Daniel wrote:
> > In the function iio_backend_oversampling_ratio_set the chan parameter
> > was added. The function can be used in contexts where the channel
is added
(tense is wrong given this patch is doing it). However it should be
in imperative.
"Add chan parameter to iio_backed_oversampling_ration_set() to allow
for contexts where the channel must be specified. Modify all
existing users."
> > must be specified. All affected files have been modified.
> >
> > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
> > ---
> > changes in v3:
> > - fix ad4851_set_oversampling_ratio function channel error
> > drivers/iio/adc/ad4851.c | 6 +++---
> > drivers/iio/adc/adi-axi-adc.c | 3 ++-
> > drivers/iio/industrialio-backend.c | 3 ++-
> > include/linux/iio/backend.h | 3 ++-
> > 4 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iio/adc/ad4851.c b/drivers/iio/adc/ad4851.c
> > index 98ebc853db79..fccfca256670 100644
> > --- a/drivers/iio/adc/ad4851.c
> > +++ b/drivers/iio/adc/ad4851.c
> > @@ -294,7 +294,7 @@ static int ad4851_scale_fill(struct iio_dev *indio_dev)
> > }
> >
> > static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
> > - const struct iio_chan_spec *chan,
> > + unsigned int chan,
>
> I think passing the channel here is misleading since this is setting the
> oversampling ratio for all channels, not just the one specified.
>
> I would suggest to make a separate patch that removes the unused
> const struct iio_chan_spec *chan parameter first.
>
> > unsigned int osr)
> > {
> > struct ad4851_state *st = iio_priv(indio_dev);
> > @@ -321,7 +321,7 @@ static int ad4851_set_oversampling_ratio(struct iio_dev *indio_dev,
> > return ret;
> > }
> >
> > - ret = iio_backend_oversampling_ratio_set(st->back, osr);
> > + ret = iio_backend_oversampling_ratio_set(st->back, chan, osr);
>
>
> Then in this patch, just pass 0 here instead of chan with a comment that
> the channel is ignored by the backend being used here.
Is it implausible that such a backend could be written for this device? If
so then I agree.
J
>
> > if (ret)
> > return ret;
> >
>
© 2016 - 2025 Red Hat, Inc.