Devicetree
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Liviu Stan <liviu.stan@analog.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Francesco Lavra" <flavra@baylibre.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux@analog.com, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 7/7] iio: temperature: ltc2983: Add support for ADT7604
Date: Wed, 20 May 2026 19:53:07 +0100	[thread overview]
Message-ID: <20260520195307.6c06760d@jic23-huawei> (raw)
In-Reply-To: <20260520181940.548759-1-liviu.stan@analog.com>

On Wed, 20 May 2026 21:19:37 +0300
Liviu Stan <liviu.stan@analog.com> wrote:

> On Mon, 18 May 2026 14:58:02 +0100 Jonathan Cameron <jic23@kernel.org> wrote:
> ...
> > > > > +		    !(st->info->supported_sensors & BIT_ULL(sensor.type)))
> > > > > +			return dev_err_probe(dev, -EINVAL,
> > > > > +					     "sensor type %d not supported on %s\n",
> > > > > +					     sensor.type, st->info->name);
> > > > > +
> > > > > +		dev_dbg(dev, "Create new sensor, type %u, channel %u",
> > > > >  			sensor.type, sensor.chan);
> > > > >      
> > > >     
> > > > > @@ -1445,8 +1782,9 @@ static int ltc2983_eeprom_cmd(struct ltc2983_data *st, unsigned int cmd,
> > > > >  
> > > > >  static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
> > > > >  {
> > > > > -	u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0, status;
> > > > >  	struct device *dev = &st->spi->dev;
> > > > > +	u32 iio_chan_t = 0, iio_chan_v = 0, iio_chan_r = 0, iio_chan_c = 0;
> > > > > +	u32 chan, iio_idx = 0, status;
> > > > >  	int ret;
> > > > >  
> > > > >  	/* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */
> > > > > @@ -1493,8 +1831,26 @@ static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
> > > > >  		    !assign_iio)
> > > > >  			continue;
> > > > >  
> > > > > +		/*
> > > > > +		 * Copper trace and leak detector sensors without a custom table
> > > > > +		 * produce only a resistance result; the chip does not populate
> > > > > +		 * the temperature result register. Emit only an IIO_RESISTANCE
> > > > > +		 * channel in this case.    
> > > > 
> > > > Do we care?  That is are they useful without the table? We could just make it
> > > > required in the binding.
> > > >     
> > > 
> > > The datasheet specifies the table is optional. But more practically, in order to
> > > be able to add accurate values to the custom table, the users first need to measure
> > > the sensor's resistance at multiple known conditions, so I think the resistance-only
> > > output is useful during that characterization phase, before the table exists. Making
> > > it required would force users to provide placeholder values just to get the driver
> > > to probe.  
> > Who cares of datasheet is crazy :)  
> 
> Fair enough :)

Nice if I could type "if" obviously!

> 
> > 
> > The initial case could I think be handled by an 'identity' table. 
> > If it's useful in more general cases maybe we should always put out the resistance
> > channels? This would be a bit like we often do for ambient light sensors, where
> > we have a computed illuminance channel (IIO_LIGHT) + the data it comes from
> > (IIO_INTENSITY)  
> 
> I checked internally and we could make the table required for leak detectors. For
> copper traces, sub-ohms variants cannot have one, but we could make it required
> for > 1ohm ones.
Great. Thanks for chasing that down.

> 
> This means we could remove the LTC2983_SENSOR_LEAK_DETECTOR from the if condition,
> and have something like this in ltc2983_setup:
> 
> if (st->sensors[chan]->type == LTC2983_SENSOR_COPPER_TRACE) {
>     if (st->sensors[chan]->n_iio_chan == 1) {
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>         continue;
>     }
> }
> + the n_iio_chan == 2 check at the end
> 
> or drop the n_iio_chan == 2 check and do something like:
> 
> if (st->sensors[chan]->type == LTC2983_SENSOR_COPPER_TRACE) {
>     if (st->sensors[chan]->n_iio_chan == 1) {
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     } else {
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_TEMP, iio_chan_t++, chan);
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     }
>     continue;
> }
> 
> if (st->sensors[chan]->type == LTC2983_SENSOR_LEAK_DETECTOR) {
>     st->iio_chan[iio_idx++] =
>         LTC2983_CHAN(IIO_COVERAGE_PERCENT, iio_chan_c++, chan);
>     st->iio_chan[iio_idx++] =
>         LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     continue;
> }
> 
> or use a switch case:
> 
> switch (st->sensors[chan]->type) {
> case LTC2983_SENSOR_COPPER_TRACE:
>     if (st->sensors[chan]->n_iio_chan == 1) {
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     } else {
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_TEMP, iio_chan_t++, chan);
>         st->iio_chan[iio_idx++] =
>             LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     }
>     continue;
> case LTC2983_SENSOR_LEAK_DETECTOR:
>     st->iio_chan[iio_idx++] =
>         LTC2983_CHAN(IIO_COVERAGE_PERCENT, iio_chan_c++, chan);
>     st->iio_chan[iio_idx++] =
>         LTC2983_CHAN(IIO_RESISTANCE, iio_chan_r++, chan);
>     continue;
> case LTC2983_SENSOR_DIRECT_ADC:
>     chan_type = IIO_VOLTAGE;
>     iio_chan = &iio_chan_v;
>     break;
> default:
>     chan_type = IIO_TEMP;
>     iio_chan = &iio_chan_t;
>     break;
> }
> st->iio_chan[iio_idx++] = LTC2983_CHAN(chan_type, (*iio_chan)++, chan);
> 
> What do you think?
> 
I don't immediately have a strong opinion. So choose which ever
looks most readable in situ.

Jonathan


> Thanks,
> Liviu


  reply	other threads:[~2026-05-20 18:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 14:46 [PATCH v2 0/7] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-05-14 14:46 ` [PATCH v2 1/7] iio: temperature: ltc2983: Fix macro parenthesization and rename Liviu Stan
2026-05-14 19:32   ` sashiko-bot
2026-05-16 16:43   ` Jonathan Cameron
2026-05-18  8:25     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 2/7] iio: temperature: ltc2983: Use local device pointer consistently Liviu Stan
2026-05-14 19:39   ` sashiko-bot
2026-05-16 16:46   ` Jonathan Cameron
2026-05-18  8:30     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 3/7] iio: temperature: ltc2983: Fix inconsistent channel wording in messages Liviu Stan
2026-05-14 19:47   ` sashiko-bot
2026-05-16 16:48   ` Jonathan Cameron
2026-05-18  8:36     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 4/7] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties Liviu Stan
2026-05-14 20:04   ` sashiko-bot
2026-05-16 16:53   ` Jonathan Cameron
2026-05-18  8:50     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 5/7] iio: core: Add IIO_COVERAGE_PERCENT channel type Liviu Stan
2026-05-14 20:16   ` sashiko-bot
2026-05-15  8:38   ` Francesco Lavra
2026-05-15  9:01     ` Stan, Liviu
2026-05-16 16:58   ` Jonathan Cameron
2026-05-18  8:53     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 6/7] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Liviu Stan
2026-05-14 20:43   ` sashiko-bot
2026-05-16 17:03   ` Jonathan Cameron
2026-05-18  8:55     ` Liviu Stan
2026-05-14 14:46 ` [PATCH v2 7/7] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-05-15  8:38   ` Francesco Lavra
2026-05-15  9:07     ` Stan, Liviu
2026-05-16 17:12   ` Jonathan Cameron
2026-05-18  8:07     ` Liviu Stan
2026-05-18 13:58       ` Jonathan Cameron
2026-05-20 18:19         ` Liviu Stan
2026-05-20 18:53           ` Jonathan Cameron [this message]
2026-05-15  6:42 ` [PATCH v2 0/7] " Stan, Liviu

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=20260520195307.6c06760d@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=flavra@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --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