[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250626192014.4dd4a270@jic23-huawei>
Date: Thu, 26 Jun 2025 19:20:14 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Matti Vaittinen <mazziesaccount@...il.com>
Cc: Lothar Rubusch <l.rubusch@...il.com>, dlechner@...libre.com,
nuno.sa@...log.com, andy@...nel.org, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/2] iio: adc: ti-adc128s052: replace literal by unit
expression
On Thu, 26 Jun 2025 08:07:19 +0300
Matti Vaittinen <mazziesaccount@...il.com> wrote:
> On 25/06/2025 20:02, Lothar Rubusch wrote:
> > Replace the literal number 1000 by MILLI from linux/units.h
> >
> > Signed-off-by: Lothar Rubusch <l.rubusch@...il.com>
> > ---
> > drivers/iio/adc/ti-adc128s052.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> > index cf271c39e663..67bc7fbd52bc 100644
> > --- a/drivers/iio/adc/ti-adc128s052.c
> > +++ b/drivers/iio/adc/ti-adc128s052.c
> > @@ -18,6 +18,7 @@
> > #include <linux/property.h>
> > #include <linux/regulator/consumer.h>
> > #include <linux/spi/spi.h>
> > +#include <linux/units.h>
> >
> > struct adc128_configuration {
> > const struct iio_chan_spec *channels;
> > @@ -189,7 +190,7 @@ static int adc128_probe(struct spi_device *spi)
> > "failed to read '%s' voltage",
> > config->refname);
> >
> > - adc->vref_mv = ret / 1000;
> > + adc->vref_mv = ret / MILLI;
>
> This makes no sense to me. What does it mean we divide the micro volts
> by 'milli'? It is clear when we divide micro volts by 1000 that we get
> milli volts. Also, the mv suffix in variable makes units clear already,
> division by MILLI just obfuscates things. I'd keep it as 1000.
>
ret / (MICRO / MILLI) would be more descriptive as indicates
we are converting form microvolts to milivolts.
> I would just drop this unless Jonathan disagrees.
>
> Yours,
> -- Matti
Powered by blists - more mailing lists