Re: [PATCH v8 10/11] iio: adc: ad7768-1: add filter type and oversampling ratio attributes
From: Jonathan Cameron
Date: Sun May 18 2025 - 13:04:16 EST
> * DMA (thus cache coherency maintenance) may require the
> @@ -326,11 +337,37 @@ static int ad7768_send_sync_pulse(struct ad7768_state *st)
>
> static void ad7768_fill_samp_freq_tbl(struct ad7768_state *st)
> {
> - unsigned int i;
> + unsigned int i, samp_freq_avail, freq_filtered, len = 0;
If you are spinning again, please split the len = 0 onto it's own
unsigned int len = 0;
to avoid mixing assigning and non assigning declarations
as they are a little hard to spot when mixed up!
> +
> + freq_filtered = DIV_ROUND_CLOSEST(st->mclk_freq, st->oversampling_ratio);
> + for (i = 0; i < ARRAY_SIZE(ad7768_mclk_div_rates); i++) {
> + samp_freq_avail = DIV_ROUND_CLOSEST(freq_filtered, ad7768_mclk_div_rates[i]);
> + /* Sampling frequency cannot be lower than the minimum of 50 SPS */
> + if (samp_freq_avail < 50)
> + continue;
> +
> + st->samp_freq_avail[len++] = samp_freq_avail;
> + }
> +
> + st->samp_freq_avail_len = len;
> +}