lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdJTcDs4SgR8NPcUJ4MX9sG2e+8t0bswDbQ8WkwNzK0hA@mail.gmail.com>
Date: Wed, 30 Apr 2025 01:40:03 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Jonathan Santos <Jonathan.Santos@...log.com>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org, andy@...nel.org, 
	nuno.sa@...log.com, Michael.Hennerich@...log.com, marcelo.schmitt@...log.com, 
	jic23@...nel.org, robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org, 
	marcelo.schmitt1@...il.com, linus.walleij@...aro.org, brgl@...ev.pl, 
	lgirdwood@...il.com, broonie@...nel.org, jonath4nns@...il.com, 
	dlechner@...libre.com, Pop Paul <paul.pop@...log.com>
Subject: Re: [PATCH v6 10/11] iio: adc: ad7768-1: add filter type and
 oversampling ratio attributes

On Mon, Apr 28, 2025 at 3:14 AM Jonathan Santos
<Jonathan.Santos@...log.com> wrote:
>
> Separate filter type and decimation rate from the sampling frequency
> attribute. The new filter type attribute enables sinc3, sinc3+rej60
> and wideband filters, which were previously unavailable.
>
> Previously, combining decimation and MCLK divider in the sampling
> frequency obscured performance trade-offs. Lower MCLK divider
> settings increase power usage, while lower decimation rates reduce
> precision by decreasing averaging. By creating an oversampling
> attribute, which controls the decimation, users gain finer control
> over performance.
>
> The addition of those attributes allows a wider range of sampling
> frequencies and more access to the device features. Sampling frequency
> table is updated after every digital filter parameter change.

...

> +static int ad7768_get_filter_type_attr(struct iio_dev *dev,
> +                                      const struct iio_chan_spec *chan);
> +static int ad7768_set_fil_type_attr(struct iio_dev *dev,
> +                                   const struct iio_chan_spec *chan, unsigned int filter);

Would it be possible to avoid forward declarations?

...

>  static void ad7768_fill_samp_freq_tbl(struct ad7768_state *st)
>  {
> -       int i;
> +       int i, freq_filtered, len = 0;

Should 'i' be signed?

> +
> +       freq_filtered = DIV_ROUND_CLOSEST(st->mclk_freq, st->oversampling_ratio);
> +       for (i = 0; i < ARRAY_SIZE(ad7768_mclk_div_rates); i++) {
> +               st->samp_freq_avail[len] = DIV_ROUND_CLOSEST(freq_filtered,
> +                                                            ad7768_mclk_div_rates[i]);
> +               /* Sampling frequency cannot be lower than the minimum of 50 SPS */
> +               if (st->samp_freq_avail[len] >= 50)
> +                       len++;
> +       }
> +       st->samp_freq_avail_len = len;
> +}

...

> +       dec_rate = clamp_t(unsigned int, dec_rate, 32, max_dec_rate);

Can't clamp() be used? _t variants are not very good and may play a
bad joke on subtle cases.

...

> +               /*
> +                * Decimations 8 (idx 0) and 16 (idx 1) are set in the
> +                * FILTER[6:4] field. The other decimations are set in the
> +                * DEC_RATE[2:0] field, and the idx need to be offsetted by two.

needs

> +                */

...

> +       /*
> +        * The decimation for SINC3 filters are configured in different
> +        * registers

Missing period at the end.

> +        */

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ