lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2893324.mvXUDI8C0e@fw-rgant>
Date: Wed, 17 Sep 2025 17:46:00 +0200
From: Romain Gantois <romain.gantois@...tlin.com>
To: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
 Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>, Jonathan Cameron <jic23@...nel.org>,
 Nuno Sá <nuno.sa@...log.com>,
 Andy Shevchenko <andy@...nel.org>, David Lechner <dlechner@...libre.com>
Cc: Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
 linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
 linux-iio@...r.kernel.org
Subject: Re: [PATCH 2/4] iio: add processed write API

Hello David,

On Tuesday, 16 September 2025 21:23:04 CEST David Lechner wrote:
> On 9/16/25 5:24 AM, Romain Gantois wrote:
> > Add a function to allow IIO consumers to write a processed value to a
...
> > +		case IIO_VAL_FRACTIONAL:
> > +			tmp_num = (s64)processed * (s64)scale_val2;
> > +			tmp_den = scale_val;
> > +			break;
> > +		case IIO_VAL_FRACTIONAL_LOG2:
> > +			tmp_num = (s64)processed << scale_val2;
> > +			tmp_den = scale_val;
> > +			break;
> > +		default:
> > +			return -EINVAL;
> > +		}
> > +
> > +		tmp_den *= scale;
> > +
> > +		*raw = div64_s64(tmp_num, tmp_den);
> > +	}
> 
> It can be quite tricky to get all of these combinations right. I would
> prefer if added some unit tests like we did in [1].
> 
> [1]:
> https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=tes
> ting&id=c732e60ee10ed0611a59513cbf9c8d35fbe7cf65

Agreed, that would be nice, I'll look into it.

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ