Re: [PATCH v4 06/14] iio: adc: ad7768: Add configurable sampling modes
From: Jonathan Cameron
Date: Sun Aug 23 2026 - 15:25:54 EST
On Fri, 21 Aug 2026 16:06:59 +0200
Janani Sunil <janani.sunil@xxxxxxxxxx> wrote:
> Derive the available output data rates from MCLK and expose per-channel
> sampling frequency and filter controls.
>
> Select the fastest compatible power mode for the enabled channels and
> map matching sampling frequency and filter combinations onto the two
> hardware channel profiles. Configure the data clock divider and wait for
> the selected filters to settle before capture.
>
> Signed-off-by: Janani Sunil <janani.sunil@xxxxxxxxxx>
More minor stuff.
J
> ---
> drivers/iio/adc/ad7768.c | 580 ++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 543 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7768.c b/drivers/iio/adc/ad7768.c
> index 34233ad6cfca..08d8e97d58fc 100644
> --- a/drivers/iio/adc/ad7768.c
> +++ b/drivers/iio/adc/ad7768.c
> +static int ad7768_apply_channel_modes(struct iio_dev *indio_dev,
> + const unsigned long *scan_mask)
> +{
> + enum ad7768_filter_type mode_filter[AD7768_NUM_CHANNEL_MODES];
> + unsigned int mode_freq[AD7768_NUM_CHANNEL_MODES];
> + bool mode_used[AD7768_NUM_CHANNEL_MODES] = { };
> struct ad7768_state *st = iio_priv(indio_dev);
> unsigned int channel_mask;
> unsigned int standby_mask;
> + unsigned int max_freq = 0;
> + struct device *dev;
> + unsigned int c;
> int ret;
>
> + guard(mutex)(&st->lock);
> + dev = regmap_get_device(st->regmap);
I can't see why this needs to be under the lock. I'd just do
it at declaration above.
> +
> +
> +static struct iio_chan_spec_ext_info ad7768_ext_info[] = {
> + IIO_ENUM("filter_type", IIO_SEPARATE,
> + &ad7768_filter_types_enum),
IIO_ENUM("filter_type", IIO_SEPARATE, &ad7768_filter_types_enum),
IIO_ENUM_AVAILABLE("filter_type", IIO_SEPARATE, &ad7768_filter_types_enum),
First line easily fits and second is only just over 80 chars. So i'd
do one line for each.
> + IIO_ENUM_AVAILABLE("filter_type", IIO_SEPARATE,
> + &ad7768_filter_types_enum),
> + { }
> +};