mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/6] iio: adc: ad7124: support fractional sampling_frequency
Date: Fri, 12 Sep 2025 09:25:41 -0500	[thread overview]
Message-ID: <889408fb-e7c5-4a1e-be96-1f632e97469e@baylibre.com> (raw)
In-Reply-To: <CAHp75VdMSr400YokZfv8SAkt-M8kuw7gt4+eCBb68xt7ipKJbQ@mail.gmail.com>

On 9/11/25 11:45 PM, Andy Shevchenko wrote:
> On Fri, Sep 12, 2025 at 12:42 AM David Lechner <dlechner@baylibre.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;
> 
> 


  reply	other threads:[~2025-09-12 14:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 21:41 [PATCH v2 0/6] iio: adc: ad7124: add filter support David Lechner
2025-09-11 21:42 ` [PATCH v2 1/6] iio: adc: ad7124: use clamp() David Lechner
2025-09-11 21:42 ` [PATCH v2 2/6] iio: adc: ad7124: use read_avail() for scale_available David Lechner
2025-09-11 21:42 ` [PATCH v2 3/6] iio: adc: ad7124: use guard(mutex) to simplify return paths David Lechner
2025-09-12  4:39   ` Andy Shevchenko
2025-09-12 14:19     ` David Lechner
2025-09-12 17:15       ` Andy Shevchenko
2025-09-12 17:41         ` David Lechner
2025-09-12 18:07           ` Andy Shevchenko
2025-09-13 13:40             ` Jonathan Cameron
2025-09-11 21:42 ` [PATCH v2 4/6] iio: adc: ad7124: support fractional sampling_frequency David Lechner
2025-09-12  4:45   ` Andy Shevchenko
2025-09-12 14:25     ` David Lechner [this message]
2025-09-11 21:42 ` [PATCH v2 5/6] iio: adc: ad7124: add filter support David Lechner
2025-09-12  4:49   ` Andy Shevchenko
2025-09-12 14:27     ` David Lechner
2025-09-13 13:42       ` Jonathan Cameron
2025-09-15  6:46         ` Andy Shevchenko
2025-09-11 21:42 ` [PATCH v2 6/6] iio: ABI: document "sinc4+rej60" filter_type David Lechner
2025-09-12  4:50 ` [PATCH v2 0/6] iio: adc: ad7124: add filter support Andy Shevchenko
2025-09-13 13:43   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=889408fb-e7c5-4a1e-be96-1f632e97469e@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®