Devicetree
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Stan, Liviu" <Liviu.Stan@analog.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	"Sa, Nuno" <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" <linux-iio@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] iio: temperature: ltc2983: Add support for ADT7604
Date: Tue, 12 May 2026 19:25:25 +0300	[thread overview]
Message-ID: <agNUdXTTzXq5M4ST@ashevche-desk.local> (raw)
In-Reply-To: <SA5PR03MB83774C631680E4E48B5655CAF6392@SA5PR03MB8377.namprd03.prod.outlook.com>

On Tue, May 12, 2026 at 09:37:57AM +0000, Stan, Liviu wrote:
> On Tue, May 12, 2026 Andy Shevchenko wrote:
> > > > >  #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.
> > >
> > > I said I would change this in v2, but on second look, I think it would be better
> > > to keep LTC2983_CHAN_START_ADDR without a (base) parameter. The base
> > > parameter in LTC2983_CHAN_RES_ADDR exists because the ADT7604 adds a
> > > second result register bank, so the base genuinely varies. For channel
> > assignment
> > > there is only one bank, so adding a base parameter would make the macro
> > look
> > > configurable when it isn't and force callers to always pass
> > > LTC2983_CHAN_ASSIGN_START_REG.
> > 
> > Do the names of the definitions _START_ADDR and _RES_ADDR come directly
> > from
> > the datasheet?  Also, given the above explanation I would see rather (bank)
> > than (base) there. With this it makes less attractive for a change that I
> > suggested earlier.
> > 
> > > Happy to change if you still prefer consistency.
> > 
> > With current names they sound like they are semantically tighten, when in
> > practice it's not so. There are options:
> > - move to (bank) and leave as currently done
> > - synchronise them and use (base) in both cases
> > - rename one or the other to be different by the name, so less confusion is
> > added
> > 
> > Your choice needs to be based on the datasheet explanation for these
> > registers.
> 
> The datasheet calls the memory regions "Channel Assignment Data"
> (0x0200-0x024F),  "Temperature Result Memory" (0x0010-0x005F) and
> "Resistance Result Memory" (0x060-0x0AF). Each region is a flat array of
> 4-byte slots, one per channel, so LTC2983_CHAN_ in both macro names
> refers to the offset of a specific channel's slot within the enclosing region.
> But I agree that it can easily create confusion.
> 
> Given that, I think it would be best to rename
> LTC2983_CHAN_START_ADDR(chan) to LTC2983_CHAN_ASSIGN_ADDR(chan),
> which aligns it with the existing LTC2983_CHAN_ASSIGN_START_REG
> constant and LTC2983_CHAN_RES_ADDR(chan, base) to
> LTC2983_RESULT_ADDR(chan, base). I would also keep (base) rather than 
> (bank) for the parameter name, since the macro expects the base address 
> of the memory region.
> 
> So, in the end we would have:
> #define LTC2983_CHAN_ASSIGN_ADDR(chan) \
> 			((((chan) - 1) * 4) + LTC2983_CHAN_ASSIGN_START_REG)
> #define LTC2983_RESULT_ADDR(chan, base) \
> 			((((chan) - 1) * 4) + (base))

This is better. Thanks!
Maybe others can propose even better ones, dunno, but these work for me.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-05-12 16:25 UTC|newest]

Thread overview: 36+ 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-05-06 13:06     ` Stan, Liviu
2026-05-06 17:26       ` Conor Dooley
2026-05-07  8:53         ` Stan, Liviu
2026-04-28 14:58   ` Jonathan Cameron
2026-05-06 14:52     ` Stan, Liviu
2026-05-07 10:35       ` 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
2026-05-07 15:31     ` Stan, Liviu
2026-05-08  7:44       ` Andy Shevchenko
2026-05-12  7:12         ` Stan, Liviu
2026-05-12  7:57           ` Andy Shevchenko
2026-05-12  9:37             ` Stan, Liviu
2026-05-12 16:25               ` Andy Shevchenko [this message]
2026-04-28 11:14   ` Nuno Sá
2026-05-07 17:25     ` Stan, Liviu
2026-05-08  9:19       ` Nuno Sá
2026-05-08 11:14         ` Jonathan Cameron
2026-05-08 12:46           ` Stan, Liviu
2026-05-08 13:44             ` Nuno Sá
2026-05-08 14:48               ` Stan, Liviu
2026-05-08 16:13                 ` Nuno Sá
2026-05-09 14:46                   ` Jonathan Cameron
2026-05-11  7:52                     ` Stan, Liviu
2026-05-11 11:18                       ` Jonathan Cameron
2026-05-11 12:02                         ` Stan, Liviu
2026-05-12  8:24                           ` Nuno Sá
2026-05-12 10:55                             ` Jonathan Cameron
2026-05-12 11:06                               ` Nuno Sá
2026-05-12 11:55                             ` Stan, Liviu
2026-05-12 12:06                               ` Nuno Sá
2026-05-12 12:26                                 ` Stan, Liviu
2026-05-12 15:56                                   ` Jonathan Cameron

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=agNUdXTTzXq5M4ST@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Liviu.Stan@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=Nuno.Sa@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=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