[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <889408fb-e7c5-4a1e-be96-1f632e97469e@baylibre.com>
Date: Fri, 12 Sep 2025 09:25:41 -0500
From: David Lechner <dlechner@...libre.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>, Nuno Sá
<nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/6] iio: adc: ad7124: support fractional
sampling_frequency
On 9/11/25 11:45 PM, Andy Shevchenko wrote:
> On Fri, Sep 12, 2025 at 12:42 AM David Lechner <dlechner@...libre.com> wrote:
>>
>> Modify the attribute read/write functions for sampling_frequency and
>> filter_low_pass_3db_frequency to return fractional values.
>>
>> These ADCs support output data rates in the single digits, so being
>> able to specify fractional values is necessary to use all possible
>> sampling frequencies.
>
> ...
>
>> factor = 32 * 4; /* N = 4 for default sinc4 filter. */
>> - odr_sel_bits = clamp(DIV_ROUND_CLOSEST(fclk, odr * factor), 1, 2047);
>> + odr_sel_bits = DIV_ROUND_CLOSEST(fclk, odr * factor +
>> + odr_micro * factor / MICRO);
>
>> + odr_sel_bits = clamp(odr_sel_bits, 1, 2047);
>
> I would rather see this clamp() call to be the part of
> cfg.odr_sel_bits() assignment, otherwise the above line and this
> operate on the semantically (slightly) different data. So, the first
> line should use different variable name, or the second, like
> odr_sel_bits_clamped.
If we moved it, then we would unnecessarily clear the cfg.live bit
in cases where clamping changed the value.
In a later commit, this gets combined to a single assignment so
not much point in adding a 2nd variable temporarily.
>
>> if (odr_sel_bits != st->channels[channel].cfg.odr_sel_bits)
>> st->channels[channel].cfg.live = false;
>>
>> - /* fADC = fCLK / (FS[10:0] x 32) */
>> - st->channels[channel].cfg.odr = DIV_ROUND_CLOSEST(fclk, odr_sel_bits *
>> - factor);
>> st->channels[channel].cfg.odr_sel_bits = odr_sel_bits;
>
>
Powered by blists - more mailing lists