From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
Cc: rodrigo.alencar@analog.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH v4 3/7] iio: frequency: adf41513: driver implementation
Date: Mon, 19 Jan 2026 19:07:10 +0200 [thread overview]
Message-ID: <aW5kk6K30Izckvg5@smile.fi.intel.com> (raw)
In-Reply-To: <hgy3bcrqqsvt7pobhnzuvwzhb2taetpxltkaxpigmmlvmlirod@v6anhmrsvv2r>
On Mon, Jan 19, 2026 at 04:37:09PM +0000, Rodrigo Alencar wrote:
> On 26/01/19 03:42PM, Andy Shevchenko wrote:
> > On Mon, Jan 19, 2026 at 11:21:59AM +0000, Rodrigo Alencar wrote:
> > > On 26/01/19 09:31AM, Andy Shevchenko wrote:
> > > > On Fri, Jan 16, 2026 at 02:32:22PM +0000, Rodrigo Alencar via B4 Relay wrote:
...
> > > > > +static int adf41513_parse_uhz(const char *str, u64 *freq_uhz)
> > > > > +{
> > > > > + u64 uhz = 0;
> > > > > + int f_count = ADF41513_HZ_DECIMAL_PRECISION;
> > > > > + bool frac_part = false;
> > > > > +
> > > > > + if (str[0] == '+')
> > > > > + str++;
> > > > > +
> > > > > + while (*str && f_count > 0) {
> > > > > + if ('0' <= *str && *str <= '9') {
> > > > > + uhz = uhz * 10 + *str - '0';
> > > > > + if (frac_part)
> > > > > + f_count--;
> > > > > + } else if (*str == '\n') {
> > > > > + if (*(str + 1) == '\0')
> > > > > + break;
> > > > > + return -EINVAL;
> > > >
> > > > > + } else if (*str == '.' && !frac_part) {
> > > >
> > > > This can be found by strchr() / strrchr() (depending on the expectations of
> > > > the input).
> > > >
> > > > > + frac_part = true;
> > > > > + } else {
> > > > > + return -EINVAL;
> > > > > + }
> > > > > + str++;
> > > > > + }
> > > >
> > > > With the above the rest becomes just a couple of simple_strtoull() calls with
> > > > a couple of int_pow(10) calls (and some validation on top).
> > > >
> > > > > + for (; f_count > 0; f_count--)
> > > > > + uhz *= 10;
> > > >
> > > > This is int_pow(10).
> > > >
> > > > > + *freq_uhz = uhz;
> > > > > +
> > > > > + return 0;
> > > > > +}
> > >
> > > The current implementation is kind of a stripped version of
> > > __iio_str_to_fixpoint(). Would you prefer something like this, then?:
> >
> > Do they have most of the parts in common? If so, why can't we use
> > __iio_str_to_fixpoint() directly? Or why can't we slightly refactor
> > that to give us the results we need here?
>
> __iio_str_to_fixpoint() only parses "int" chunks, adf41513_parse_uhz
> was modified to accomodate the u64 parsing removing unnecessary stuff.
But why? The fractional part most likely will be kept int (it's up to 10⁻⁹).
The integer can be bigger than 10⁹?
> I am preparing V5 to use simple_strtoull. Thanks for early review
> and suggestions.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-01-19 17:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 14:32 [PATCH v4 0/7] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar via B4 Relay
2026-01-16 14:32 ` [PATCH v4 1/7] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar via B4 Relay
2026-01-16 14:35 ` Krzysztof Kozlowski
2026-01-16 14:32 ` [PATCH v4 2/7] units: Add HZ_PER_GHZ definition Rodrigo Alencar via B4 Relay
2026-01-16 15:26 ` Andy Shevchenko
2026-01-16 19:01 ` Jonathan Cameron
2026-01-16 14:32 ` [PATCH v4 3/7] iio: frequency: adf41513: driver implementation Rodrigo Alencar via B4 Relay
2026-01-16 19:29 ` Jonathan Cameron
2026-01-19 13:10 ` Rodrigo Alencar
2026-01-19 7:31 ` Andy Shevchenko
2026-01-19 11:21 ` Rodrigo Alencar
2026-01-19 13:42 ` Andy Shevchenko
2026-01-19 16:37 ` Rodrigo Alencar
2026-01-19 17:07 ` Andy Shevchenko [this message]
2026-01-20 10:43 ` Rodrigo Alencar
2026-01-20 11:24 ` Andy Shevchenko
2026-01-20 13:07 ` Rodrigo Alencar
2026-01-20 13:38 ` Andy Shevchenko
2026-01-21 9:41 ` Rodrigo Alencar
2026-01-21 9:52 ` Andy Shevchenko
2026-01-21 14:21 ` Nuno Sá
2026-01-22 19:33 ` Jonathan Cameron
2026-01-16 14:32 ` [PATCH v4 4/7] iio: frequency: adf41513: handle LE synchronization feature Rodrigo Alencar via B4 Relay
2026-01-16 14:32 ` [PATCH v4 5/7] iio: frequency: adf41513: features on frequency change Rodrigo Alencar via B4 Relay
2026-01-16 15:36 ` Andy Shevchenko
2026-01-16 14:32 ` [PATCH v4 6/7] docs: iio: add documentation for adf41513 driver Rodrigo Alencar via B4 Relay
2026-01-16 14:32 ` [PATCH v4 7/7] Documentation: ABI: testing: add common ABI file for iio/frequency Rodrigo Alencar via B4 Relay
2026-01-16 15:28 ` Andy Shevchenko
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=aW5kk6K30Izckvg5@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=455.rodrigo.alencar@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@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