public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>,
	rodrigo.alencar@analog.com, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-doc@vger.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 v6 2/8] iio: core: add fixed point parsing with 64-bit parts
Date: Sat, 7 Feb 2026 16:59:38 +0000	[thread overview]
Message-ID: <20260207165938.59d6895f@jic23-huawei> (raw)
In-Reply-To: <c4efbcda461cdfd58c7a7ab8b8c29c5f47fbda01.camel@gmail.com>

On Tue, 03 Feb 2026 10:04:01 +0000
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Tue, 2026-02-03 at 09:26 +0000, Rodrigo Alencar wrote:
> > On 26/02/02 09:57AM, Nuno Sá wrote:  
> > > On Fri, 2026-01-30 at 10:06 +0000, Rodrigo Alencar via B4 Relay wrote:  
> > > > From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > > > 
> > > > Add iio_str_to_fixpoint64() function that leverages simple_strtoull()
> > > > to parse numbers from a string.
> > > > A helper function __iio_str_to_fixpoint64() replaces
> > > > __iio_str_to_fixpoint() implementation, extending its usage for
> > > > 64-bit fixed-point parsing.  
> > 
> > ...
> >   
> > > >  /**
> > > >   * __iio_str_to_fixpoint() - Parse a fixed-point number from a string
> > > >   * @str: The string to parse
> > > > @@ -895,63 +1026,43 @@ static ssize_t iio_read_channel_info_avail(struct device *dev,
> > > >  static int __iio_str_to_fixpoint(const char *str, int fract_mult,
> > > >  				 int *integer, int *fract, bool scale_db)
> > > >  {
> > > > -	int i = 0, f = 0;
> > > > -	bool integer_part = true, negative = false;
> > > > +	s64 integer64, fract64;
> > > > +	int ret;
> > > >  
> > > > -	if (fract_mult == 0) {
> > > > -		*fract = 0;
> > > > +	ret = __iio_str_to_fixpoint64(str, fract_mult, &integer64, &fract64,
> > > > +				      scale_db);
> > > > +	if (ret)
> > > > +		return ret;  
> > > 
> > > I know it feels tempting to do the above while adding the 64bit variant. But isn't the
> > > overflow safety also an issue on the 32bit variant? IMO, we should first have a patch
> > > adding the overflow safety with a Fixes tag and then add 64bit support.  
> > 
> > I think handling 64-bit support after taclking the overflow issue
> > would require changes on top of previous ones, which might get a messy
> > commit history, no? Mostly because the 64-bit variant of the function
> > is being used inside the 32-bit one. Also, the added auxiliary function
> > that implements the overflow check parses u64, which allowed for the
> > removal of the while loop in the __iio_str_to_fixpoint() implementation.  
> 
> Typically we do fixes before because we might want to backport them and we just want to backport the
> fix (so not the 64bit support). But we never really had any known issues with the current API
> (AFAIK) so it might be ok as-is. Will defer to Jonathan.

When we say overflow, I assume we just get the wrong value?  If so
then I doubt anyone ever noticed it.  Worth tidying up as a useability
improvement but not sure it's worth back porting.

Jonathan

> 
> - Nuno Sá
> > before this assignment.
> >    


  reply	other threads:[~2026-02-07 16:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 10:06 [PATCH v6 0/8] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar via B4 Relay
2026-01-30 10:06 ` [PATCH v6 1/8] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar via B4 Relay
2026-01-30 10:06 ` [PATCH v6 2/8] iio: core: add fixed point parsing with 64-bit parts Rodrigo Alencar via B4 Relay
2026-02-02  9:57   ` Nuno Sá
2026-02-03  9:26     ` Rodrigo Alencar
2026-02-03 10:04       ` Nuno Sá
2026-02-07 16:59         ` Jonathan Cameron [this message]
2026-02-04  1:45   ` Andy Shevchenko
2026-02-04  9:42     ` Rodrigo Alencar
2026-02-04  9:57       ` Andy Shevchenko
2026-02-04 10:28         ` Rodrigo Alencar
2026-02-04 10:34           ` Andy Shevchenko
2026-02-07 17:02             ` Jonathan Cameron
2026-02-08 13:24               ` Andy Shevchenko
2026-01-30 10:06 ` [PATCH v6 3/8] iio: test: add kunit test for fixed-point parsing Rodrigo Alencar via B4 Relay
2026-02-03 15:38   ` Andy Shevchenko
2026-01-30 10:06 ` [PATCH v6 4/8] iio: frequency: adf41513: driver implementation Rodrigo Alencar via B4 Relay
2026-02-07 17:21   ` Jonathan Cameron
2026-01-30 10:06 ` [PATCH v6 5/8] iio: frequency: adf41513: handle LE synchronization feature Rodrigo Alencar via B4 Relay
2026-01-30 10:06 ` [PATCH v6 6/8] iio: frequency: adf41513: features on frequency change Rodrigo Alencar via B4 Relay
2026-01-30 10:06 ` [PATCH v6 7/8] docs: iio: add documentation for adf41513 driver Rodrigo Alencar via B4 Relay
2026-01-30 10:06 ` [PATCH v6 8/8] Documentation: ABI: testing: add common ABI file for iio/frequency Rodrigo Alencar via B4 Relay
2026-02-07 17:24   ` Jonathan Cameron
2026-02-11 13:52     ` Rodrigo Alencar
2026-02-14 14:44       ` 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=20260207165938.59d6895f@jic23-huawei \
    --to=jic23@kernel.org \
    --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=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=noname.nuno@gmail.com \
    --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