From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC88139C62F for ; Tue, 3 Feb 2026 10:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770113005; cv=none; b=maMuX1OyfviRZP0ARwmGnMadolzNLW3Fj1iT2D41drRGsNQmTqnwFvSfY0AXkIy1cK2awblYElNFZ7oqRDndc6ruBCV3fTqRRv9T+M4Wrx5Oe+omtlpv9QDUv6OAvMlQ2vRDE1Pc/kMMWyLwXZrxPd2Z9GlFSFtpuQcM5S0JxFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770113005; c=relaxed/simple; bh=ao5SwoLNTIiHJURJeN/qxgiD0uarUaiktckItiBuuxc=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=V2phnDiOaNvxPfNjWDe8ehi345R9UYW0VcKDAPx6Ab3levArhiaGIFEPtISGYYdNElVF+i6M97/Twwlgv4uOXYVd+vW7CCjtBeMdniHdt6ig4mAETNrq038BJCynlcPVyHE31OQ3uSdsFesab9AOPdcxpvOrhTmeddBMSORSBdI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q+gdIPF3; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q+gdIPF3" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-435903c4040so3610600f8f.3 for ; Tue, 03 Feb 2026 02:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770112999; x=1770717799; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=9t5Fe5bGozogr0ZNYAWcRlOMGPdLPrptTIS9SavKeiw=; b=Q+gdIPF3SmpI+vGeoYLyresfGoXQJErwLP4kt0vS7MHbHziBXkiMJr4FGSgqTg3Ba2 kYlDInqM//a5uMC4b+BFNwDQ1xhlKT5hFw0ESwENUKUyvnind9qlcMAkhn37VDPfYruZ rI2JA35kbaqVw02DEAqEeJCjf+GnST5hjsQtlz2k1Hye41gYF15v4mvTVBBu0WoI9qRE bx1i+yj6Fo0v1J4E/qDHIPrVE9AX+MkJndllfCIG1ZJ84uskaOXhONfTmZrEXIptq9VM QrrBU1TBFPdNSaAhJa3CzYgpiI6BREvOM1nCKtnzLK2+/Dc0nbLQ/y9yUUJUsSq/+7lQ MsFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770112999; x=1770717799; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9t5Fe5bGozogr0ZNYAWcRlOMGPdLPrptTIS9SavKeiw=; b=KgoT63IA3l+0UfEtzJgi1i0F1nDFgP68cQ/CCaJVWz0xQzARAGRCP7XgfKk6Ez6ZcK ZnWW9ir168wx2jCdTMKzPPYHClBfcVyYvQDWtULpiwFPRVXj+5Ugs/QHg2+0IL/aFU/X YOdVTt0GhGUwu2jK5YmGVrU+AFrKglet2T0LRFKFR6MiMR1+7wvPvNoUWiO/ebSRS4YZ GGAaUTq99I+91xLvQ8bxRDZO1xWZfDCGddKr61RiXK4fQDey12cvmI0efksiOkKH3CcD tIjeM7LP/LpFTK8t54fgZl/1vekPlUfhJGQ1/yOBv6Ac8ghx8IM00UyO9I3MLTYQSopz Pq0w== X-Forwarded-Encrypted: i=1; AJvYcCWV/SQw9CFbnogexBHbuMvuwY2g5B9LarLShR3f35+gKOmpnjPus12frb26mI+hDEIgKadyB7eGn3Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzGorFXM1Wt0pnUYrjaGgPd4V9MSGZ78tL0uwL6s07wCvAgrbaB uv7xSSjCPSTKjE9UuHEnb2Ob+cy/8rX8PGxPki7uyDxqVqnqTHM2Yi46 X-Gm-Gg: AZuq6aI5kA0S3fNNY3Mff8V2HPIQDMKeV69JoHJXKAnss5WKgx+SqWKQHmfTRxxi6NU WoBzx9RfuKi5z2Jx3B2/iQ2c6WxQsJGiqUZCU+F5WW5oCJC+oV79TH8NBiPxu0Zm1fUto6Ookhz 6kW8TaLGH0VOehzrFu1qxULdTQQ2ueyqqYpydFZV8h8I+gQC3BHpLEYs9pIe8q5uYU3bPbzIvhE NNffLhFletjsw4Uae5uMrf61ecv9Tbzjq4GP88pFDTqyaxX4PK+nasD3+HV5nQDwFyRyUuGL0kt ZAqtDnVv2yJ3rR8/9R8G8WGCCAhurl15tnrV3K3Kzt8K15odSQ356n5DdCLhSKi3dIDlVAs3A9w DBleqkiqTRSs6mlGFsxauuBWWu3lpw0F3qZK09HLXVQnFWYt2gbbJlQNPuOv8dCjMfFEiKkkopF 3BcuXutqoU4CXPmtvCF8IzFb2GR03vrQ== X-Received: by 2002:a05:6000:1ac8:b0:432:c37c:d83a with SMTP id ffacd0b85a97d-435f3a86321mr22562027f8f.15.1770112999096; Tue, 03 Feb 2026 02:03:19 -0800 (PST) Received: from [192.168.1.187] ([148.63.225.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e135422csm52922361f8f.40.2026.02.03.02.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 02:03:18 -0800 (PST) Message-ID: Subject: Re: [PATCH v6 2/8] iio: core: add fixed point parsing with 64-bit parts From: Nuno =?ISO-8859-1?Q?S=E1?= To: 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 Cc: Jonathan Cameron , David Lechner , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet Date: Tue, 03 Feb 2026 10:04:01 +0000 In-Reply-To: References: <20260130-adf41513-iio-driver-v6-0-cf46239026bc@analog.com> <20260130-adf41513-iio-driver-v6-2-cf46239026bc@analog.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-02-03 at 09:26 +0000, Rodrigo Alencar wrote: > On 26/02/02 09:57AM, Nuno S=C3=A1 wrote: > > On Fri, 2026-01-30 at 10:06 +0000, Rodrigo Alencar via B4 Relay wrote: > > > From: Rodrigo Alencar > > >=20 > > > 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. >=20 > ... >=20 > > > =C2=A0/** > > > =C2=A0 * __iio_str_to_fixpoint() - Parse a fixed-point number from a = string > > > =C2=A0 * @str: The string to parse > > > @@ -895,63 +1026,43 @@ static ssize_t iio_read_channel_info_avail(str= uct device *dev, > > > =C2=A0static int __iio_str_to_fixpoint(const char *str, int fract_mul= t, > > > =C2=A0 int *integer, int *fract, bool scale_db) > > > =C2=A0{ > > > - int i =3D 0, f =3D 0; > > > - bool integer_part =3D true, negative =3D false; > > > + s64 integer64, fract64; > > > + int ret; > > > =C2=A0 > > > - if (fract_mult =3D=3D 0) { > > > - *fract =3D 0; > > > + ret =3D __iio_str_to_fixpoint64(str, fract_mult, &integer64, &fract= 64, > > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 scale_db); > > > + if (ret) > > > + return ret; > >=20 > > 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 firs= t have a patch > > adding the overflow safety with a Fixes tag and then add 64bit support. >=20 > 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 wi= th the current API (AFAIK) so it might be ok as-is. Will defer to Jonathan. - Nuno S=C3=A1 > before this assignment. > =C2=A0