Re: [PATCH v4 06/14] iio: adc: ad7768: Add configurable sampling modes

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel
Message-ID <20260823202527.29881ee4@jic23-huawei>
On Fri, 21 Aug 2026 16:06:59 +0200
Janani Sunil <[email protected]> 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 <[email protected]>
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),
> +	{ }
> +};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.