From: Liam Beguin <liambeguin@gmail.com>
To: Peter Rosin <peda@axentia.se>
Cc: jic23@kernel.org, andy.shevchenko@gmail.com, lars@metafoo.de,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, robh+dt@kernel.org
Subject: Re: [PATCH v14 02/11] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support
Date: Thu, 10 Feb 2022 12:36:02 -0500 [thread overview]
Message-ID: <YgVNAj7kz1QbKkhy@shaak> (raw)
In-Reply-To: <fbb84b08-5d3d-3684-fdee-5ce367280857@axentia.se>
Hi Peter,
On Thu, Feb 10, 2022 at 05:42:25PM +0100, Peter Rosin wrote:
> Hi!
>
> As usual, sorry for my low bandwidth.
No worries, I understand. It's been pretty slow on my end as well.
Thanks for still making time for this :-)
> On 2022-02-08 03:04, Liam Beguin wrote:
> > Some ADCs use IIO_VAL_INT_PLUS_{NANO,MICRO} scale types.
> > Add support for these to allow using the iio-rescaler with them.
> >
> > Signed-off-by: Liam Beguin <liambeguin@gmail.com>
> > Reviewed-by: Peter Rosin <peda@axentia.se>
> > ---
> > drivers/iio/afe/iio-rescale.c | 35 +++++++++++++++++++++++++++++++++++
> > 1 file changed, 35 insertions(+)
...
> > @@ -41,6 +45,37 @@ int rescale_process_scale(struct rescale *rescale, int scale_type,
> > tmp *= rescale->numerator;
> > tmp = div_s64(tmp, 1000000000LL);
> > *val = tmp;
> > + return scale_type;
> > + case IIO_VAL_INT_PLUS_NANO:
> > + case IIO_VAL_INT_PLUS_MICRO:
> > + mult = scale_type == IIO_VAL_INT_PLUS_NANO ? GIGA : MEGA;
>
> By now, we all agree that the big numbers in this context have nothing
> to do with unit prefixes of physical quantities, so the macros are not
> really appropriate. However, in this case we have IIO_VAL_INT_PLUS_NANO
> and IIO_VAL_INT_PLUS_MICRO. Not using "NANO : MICRO" here, and instead
> go with "GIGA : MEGA" is just plain silly, if you ask me.
>
> So, either "NANO : MICRO" or "1000000000 : 1000000".
>
> I'm not sold on the macros. I frankly don't see all that much value
> in them and am perfectly fine with raw numbers. To me, it just looks
> like someone has read somewhere that constants should not appear in
> the code, and from that concluded that #define TEN 10 is a good thing
> without thinking very much about it. There is also the possibility
> that someone who has never seen these defines thinks MEGA is 2^20
> instead of 10^6, because that is a much more likely candidate for a
> define in the frist place (not everybody knows all the digits of
> 1048576 by heart and 1 << 20 many times require extra brackets that
> might make it look more complicated than it needs to be).
>
> Back to this case; the connection to the naming of IIO_VAL_INT_PLUS_NANO
> (and ..._MICRO) makes it ok to use the defines. So if you feel strongly
> about not using "1000000000 : 1000000" I'm ok with that.
I like that the macros make the number of zeros more "obvious" in a
sense, but honestly at this point, I'd rather go back to not using them.
Depending on who you ask, one way makes more sense than the other, at
least with the raw values, there's no ambiguity.
Cheers,
Liam
> Cheers,
> Peter
next prev parent reply other threads:[~2022-02-10 17:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 2:04 [PATCH v14 00/11] iio: afe: add temperature rescaling support Liam Beguin
2022-02-08 2:04 ` [PATCH v14 01/11] iio: afe: rescale: expose scale processing function Liam Beguin
2022-02-08 2:04 ` [PATCH v14 02/11] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support Liam Beguin
2022-02-10 16:42 ` Peter Rosin
2022-02-10 17:36 ` Liam Beguin [this message]
2022-02-11 14:20 ` Peter Rosin
2022-02-08 2:04 ` [PATCH v14 03/11] iio: afe: rescale: add offset support Liam Beguin
2022-02-08 13:42 ` Andy Shevchenko
2022-02-09 16:35 ` Liam Beguin
2022-02-10 16:47 ` Peter Rosin
2022-02-08 2:04 ` [PATCH v14 04/11] iio: afe: rescale: fix accuracy for small fractional scales Liam Beguin
2022-02-08 2:04 ` [PATCH v14 05/11] iio: afe: rescale: reduce risk of integer overflow Liam Beguin
2022-02-08 2:04 ` [PATCH v14 06/11] iio: afe: rescale: make use of units.h Liam Beguin
2022-02-10 17:41 ` Peter Rosin
2022-02-08 2:04 ` [PATCH v14 07/11] iio: test: add basic tests for the iio-rescale driver Liam Beguin
2022-02-08 2:04 ` [PATCH v14 08/11] iio: afe: rescale: add RTD temperature sensor support Liam Beguin
2022-02-08 2:04 ` [PATCH v14 09/11] iio: afe: rescale: add temperature transducers Liam Beguin
2022-02-08 13:46 ` Andy Shevchenko
2022-02-09 16:38 ` Liam Beguin
2022-02-08 2:04 ` [PATCH v14 10/11] dt-bindings: iio: afe: add bindings for temperature-sense-rtd Liam Beguin
2022-02-08 2:04 ` [PATCH v14 11/11] dt-bindings: iio: afe: add bindings for temperature transducers Liam Beguin
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=YgVNAj7kz1QbKkhy@shaak \
--to=liambeguin@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=robh+dt@kernel.org \
/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