Re: [PATCH 1/5] iio: backend: add support for decimation ratio set

From: Nuno Sá
Date: Fri Mar 28 2025 - 04:36:39 EST


On Mon, 2025-03-24 at 13:53 -0500, David Lechner wrote:
> On 3/24/25 4:07 AM, Pop Ioan Daniel wrote:
> > Add backend support for setting the decimation ratio used.
> >
> > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@xxxxxxxxxx>
> > ---
> >  drivers/iio/industrialio-backend.c | 18 ++++++++++++++++++
> >  include/linux/iio/backend.h        |  3 +++
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-
> > backend.c
> > index 363281272035..f4db6514944a 100644
> > --- a/drivers/iio/industrialio-backend.c
> > +++ b/drivers/iio/industrialio-backend.c
> > @@ -417,6 +417,24 @@ int iio_backend_test_pattern_set(struct iio_backend *back,
> >  }
> >  EXPORT_SYMBOL_NS_GPL(iio_backend_test_pattern_set, "IIO_BACKEND");
> >  
> > +/**
> > + * iio_backend_set_dec_rate - set decimation ratio
>
> In [1], we decided that for a similar chip we could use "decimation rate" and
> "oversampling ratio" interchangeably. And in [2], we recently added a backend
> op for setting the oversampling ratio. Would it make sense to use that here
> as well instead of introducing a new function? If not, we'll want more of an
> explanation here on what the difference is. But from what I can tell, this
> sounds very similar to the other case where they are essentially the same thing.
> On the other hand, this is internal API and not userspace ABI, so having a
> separate name might not be so bad, especially if there is a chance we would ever
> have both at the same time.

If it fits, I have preference for using existent interfaces...

- Nuno Sá
>
> [1]: https://lore.kernel.org/linux-iio/20250112122047.1e1978e0@jic23-huawei/
> [2]:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/drivers/iio/industrialio-backend.c?h=testing&id=22894e0be908791e3df011cdfac02589c2f340bd
>
> > + * @back: Backend device
> > + * @rate: Rate in decimal
> > +
> > + * Return:
> > + * 0 on success, negative error number on failure.
> > + */
> > +
> > +int iio_backend_set_dec_rate(struct iio_backend *back, unsigned int rate)
> > +{
> > + if (!rate)
> > + return -EINVAL;
> > +
> > + return iio_backend_op_call(back, set_dec_rate, rate);
> > +}
> > +EXPORT_SYMBOL_NS_GPL(iio_backend_set_dec_rate, "IIO_BACKEND");
> > +