From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Liviu Stan <liviu.stan@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: temperature: ltc2983: Add support for ADT7604
Date: Mon, 27 Apr 2026 21:23:59 +0300 [thread overview]
Message-ID: <ae-pvxKhqmkWwXdX@ashevche-desk.local> (raw)
In-Reply-To: <20260427132526.272716-3-liviu.stan@analog.com>
On Mon, Apr 27, 2026 at 04:25:08PM +0300, Liviu Stan wrote:
> The ADT7604 shares the same die as the LTC2984. It repurposes the
> custom RTD sensor type (18) as a copper trace resistance sensor
> and the custom thermistor type (27) as a leak detector, and
> removes thermocouple, diode and direct ADC sensor types.
>
> Custom RTD (type 18) becomes the copper trace sensor. Sensor
> configuration bits 21:18 are hardcoded to 0b1001 per the
> datasheet. Two variants are supported via the new
> adi,copper-trace-sub-ohm DT property: sub-ohm traces (< 1 ohm)
> have bits 17:0 cleared with no excitation current or custom
> table; standard traces (> 1 ohm) accept an optional
> resistance-to-temperature table.
>
> Custom thermistor (type 27) becomes the leak detector. Sensor
> configuration bits are hardcoded to 0b001. The custom table
> uses a resolution of 16 (20+4 bit resistance field) instead of
> 64, and is specified via the new adi,custom-leak-detector DT
> property.
>
> Both sensor types expose an IIO_RESISTANCE channel reading from
> the resistance result register bank (0x060-0x00AF), added to
> the regmap readable ranges. Scales are 1/1,024,000 for copper
> trace (result in mOhm) and 1/1024 for leak detector (result
> in Ohm).
>
> A has_copper_trace capability flag is introduced in
> ltc2983_chip_info to identify the ADT7604, following the
> existing has_temp and has_eeprom pattern.
>
> Tested on EVAL-ADT7604-AZ connected to Raspberry Pi 5 via SPI.
...
> #define LTC2983_CHAN_START_ADDR(chan) \
> (((chan - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
> -#define LTC2983_CHAN_RES_ADDR(chan) \
> - (((chan - 1) * 4) + LTC2983_TEMP_RES_START_REG)
> +#define LTC2983_CHAN_RES_ADDR(chan, base) \
> + ((((chan) - 1) * 4) + (base))
For the sake of consistency I would see (base) also to be in the _START_ADDR()
macro.
...
> + bool sub_ohm;
What does this mean? Perhaps rename to is_in_milliohms or something like that?
...
> + ret = fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires);
> + if (!ret) {
Yeah, this is in the original code. Consider at some point to make it rather
returning meaningful error codes, id est
if (fwnode_property_present(child, "adi,number-of-wires")) {
ret = fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires);
if (ret)
return ret; // or with message that we can't get property value
> + switch (n_wires) {
> + case 2:
> + rtd->sensor_config = LTC2983_RTD_N_WIRES(0);
> + break;
> + case 3:
> + rtd->sensor_config = LTC2983_RTD_N_WIRES(1);
> + break;
> + case 4:
> + rtd->sensor_config = LTC2983_RTD_N_WIRES(2);
> + break;
> + case 5:
> + /* 4 wires, Kelvin Rsense */
> + rtd->sensor_config = LTC2983_RTD_N_WIRES(3);
> + break;
> + default:
> + return dev_err_ptr_probe(dev, -EINVAL,
> + "Invalid number of wires:%u\n",
> + n_wires);
> + }
> }
...
> + if (sensor->chan < LTC2983_DIFFERENTIAL_CHAN_MIN)
> + return dev_err_ptr_probe(&st->spi->dev, -EINVAL,
Don't you have 'dev' variable to use? If not, maybe makes sense to introduce.
> + "Invalid chann:%d for RTD\n",
chann? Perhaps just "chan"?
> + sensor->chan);
> }
...
> + if (st->info->has_copper_trace) {
> + if (fwnode_property_present(child, "adi,custom-rtd")) {
> + rtd->custom = __ltc2983_custom_sensor_new(st, child,
> + "adi,custom-rtd",
> + false, 2048,
> + false);
> + if (IS_ERR(rtd->custom))
> + return ERR_CAST(rtd->custom);
> + }
> + } else {
> + rtd->custom = __ltc2983_custom_sensor_new(st, child,
> + "adi,custom-rtd",
> + false, 2048, false);
> + if (IS_ERR(rtd->custom))
> + return ERR_CAST(rtd->custom);
> + }
Seeing so many indentation noise, I think this patch starves for some
preparatory ones that make helper(s) out of the existing rather long functions
and then in a new code it will much easier to follow what gets changed and how.
...
Due to above I stopped here, because patch seems unreviewable to me. If others
are motivated more than me ans see this change nice in terms of readability,
I won't object. Personally I think it must be refactored (a lot!) before actually
adding a support of a new HW.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-04-27 18:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 13:25 [PATCH 0/2] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-04-27 13:25 ` [PATCH 1/2] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Liviu Stan
2026-04-27 19:34 ` Conor Dooley
2026-04-28 14:58 ` Jonathan Cameron
2026-04-27 13:25 ` [PATCH 2/2] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-04-27 18:23 ` Andy Shevchenko [this message]
2026-04-28 11:14 ` Nuno Sá
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=ae-pvxKhqmkWwXdX@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.stan@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh@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