[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250920125600.182971d9@jic23-huawei>
Date: Sat, 20 Sep 2025 12:56:00 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Romain Gantois <romain.gantois@...tlin.com>
Cc: 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>, Nuno Sá
<nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, David Lechner
<dlechner@...libre.com>, 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
On Wed, 17 Sep 2025 17:46:00 +0200
Romain Gantois <romain.gantois@...tlin.com> wrote:
> 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,
>
Overall code looks fine to me but unit tests would indeed be great.
Thanks,
Jonathan
Powered by blists - more mailing lists