[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfM6WzNCT=ihN=wkaY0dQwjnJ0VLSyaGVbhCw4Lg-aXAQ@mail.gmail.com>
Date: Wed, 13 Aug 2025 19:14:16 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Yusuf Alper Bilgin <y.alperbilgin@...il.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Liam Beguin <liambeguin@...il.com>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] iio: adc: ltc2497: add temperature sensor support
On Wed, Aug 13, 2025 at 6:54 PM Yusuf Alper Bilgin
<y.alperbilgin@...il.com> wrote:
>
> Support for reading the internal temperature sensor on LTC2495 and
> LTC2499 via a standard IIO temperature channel.
...
> +#define LTC2497_KELVIN_TO_CELCIUS 273
Drop it, see below why.
...
> + *val = -LTC2497_KELVIN_TO_CELCIUS * ddata->chip_info->temp_scale_mV;
Can you use kelvin_to_celsius(0) from units.h instead?
> + *val2 = ret / 1000;
> +
> + return IIO_VAL_FRACTIONAL;
...
> +#define LTC2497_T_CHAN { \
It's better to locate { on the new line.
> + .type = IIO_TEMP, \
> + .channel = 0, \
> + .address = (LTC2497_ENABLE_TEMPERATURE_CONV), \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OFFSET), \
> +}
...
> + LTC2497_CHANNELS,
Seems like a terminator, so add _MAX in the middle and remove the
trailing comma.
...
> +static const struct iio_chan_spec ltc2497core_channel_with_temperature[] = {
> + LTC2497_CHANNELS,
> + LTC2497_T_CHAN,
(Same as above may be applied to _T_CHAN, but I haven't seen the enum
to be sure)
> };
...
> struct ltc2497_chip_info {
> - u32 resolution;
> const char *name;
> + u32 resolution;
Perhaps above deserves a separate change (with the `pahole` summary),
but I don't care as it's a little change here. Leave this to Jonathan
to decide.
> + /*
> + * Represents the datasheet constant from the temperature formula:
> + * T_Kelvin = (DATAOUT * Vref) / temp_scale, where Vref is in Volts.
> + *
> + * To allow the driver to use Vref in millivolts for the calculation
> + * and also to avoid floating points, this stored value represents the
> + * datasheet constant scaled by 1000.
> + */
> + u32 temp_scale_mV;
> + bool has_temp_channel;
> };
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists