Devicetree
 help / color / mirror / Atom feed
From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: David Lechner <dlechner@baylibre.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, jic23@kernel.org,
	nuno.sa@analog.com, Michael.Hennerich@analog.com,
	andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, julianbraha@gmail.com
Subject: Re: [PATCH v4 2/4] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs
Date: Mon, 29 Jun 2026 11:57:03 -0300	[thread overview]
Message-ID: <akKHv7j22P6KczXb@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <9c6e0a74-c9c5-43ee-8eca-ae1667c51c32@baylibre.com>

> > +{										\
> > +	.type = IIO_VOLTAGE,							\
> > +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |				\
> > +			      BIT(IIO_CHAN_INFO_SCALE) |			\
> > +			      (_offl ? BIT(IIO_CHAN_INFO_SAMP_FREQ) : 0),	\
> > +	.info_mask_separate_available = _offl ? BIT(IIO_CHAN_INFO_SAMP_FREQ) : 0,\
> > +	.scan_index = 0,							\
> > +	.scan_type = {								\
> > +		.format = _sign ? IIO_SCAN_FORMAT_SIGNED_INT :			\
> > +				  IIO_SCAN_FORMAT_UNSIGNED_INT,			\
> > +		.realbits = _real_bits,						\
> > +		.storagebits = _storage_bits,					\
> > +		.shift = (_offl ? 0 : _storage_bits - _real_bits),		\
> > +		.endianness = _offl ? IIO_CPU : IIO_BE				\
> > +	},									\
> > +}
> > +
> > +#define LTC2378_BIPOLAR_DIFF_CHANNEL(_real_bits)				\
> > +	__LTC2378_DIFF_CHANNEL(1, _real_bits, (((_real_bits) > 16) ? 32 : 16), 0)
> > +
> > +#define LTC2378_UNIPOLAR_DIFF_CHANNEL(_real_bits)				\
> > +	__LTC2378_DIFF_CHANNEL(0, _real_bits, (((_real_bits) > 16) ? 32 : 16), 0)
> 
> Why not move the (((_real_bits) > 16) ? 32 : 16) into the __LTC2378_DIFF_CHANNEL()
> macro to avoid repeating it?
> 
Because that would go wrong for LTC2378_OFFLOAD_BIPOLAR_DIFF_CHANNEL() in patch 3.

> > +
> > +struct ltc2378_chip_info {
> > +	const char *name;
> > +	unsigned int internal_ref_uv;
...
> 
> > +static int ltc2378_regulator_setup(struct device *dev, struct ltc2378_state *st)
> > +{
> > +	int ret;
> > +
> > +	ret = devm_regulator_get_enable_read_voltage(dev, "refin");
> > +	if (ret < 0 && ret != -ENODEV) {
> > +		return dev_err_probe(dev, ret, "failed to read refin regulator\n");
> > +	} else if (ret > 0) {
> 
> Else is not needed here.
Why not? Intendend flow/logic is to get and use refin for devices that have it
(currently only one chip has). Except for that chip that has 'refin', other
chips have only 'ref' and no internal reference. Also, the chip that has 'refin'
doesn't have 'ref' so it uses an internal reference when 'refin' is not found.
Anyways, the driver can use 'refin' if there is one available, no?

P.S. Will separate regulator logic according to chip type.

> 
> > +		st->ref_uV = ret;
> > +		return 0;
> > +	}
> > +
> > +	if (st->info->internal_ref_uv) {
> > +		st->ref_uV = st->info->internal_ref_uv;
> > +		return 0;
> > +	}
> 
> I would be tempted to have two separate functions here and only call one depending
> on the chip. Otherwise, it allows incorrect devicetree.

Hmm, I see. Drat, I was hoping to avoid checking for specific chip parts to
handle regulators. dtbs_check should error if a chip other than ltc2338 has 'refin'.
Anyways, I see maintainers will probably prefer the chip specific init flow.

> 
> > +
> > +	ret = devm_regulator_get_enable_read_voltage(dev, "ref");
> > +	if (ret < 0)
> > +		return dev_err_probe(dev, ret, "failed to read ref regulator\n");
> > +
> > +	st->ref_uV = ret;
> > +
> > +	return 0;
> > +}
> > +

Will adjust according to other comments as well.

Thanks,
Marcelo

  reply	other threads:[~2026-06-29 14:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 14:34 [PATCH v4 0/4] iio: adc: Add support for LTC2378 and similar ADCs Marcelo Schmitt
2026-06-25 14:34 ` [PATCH v4 1/4] dt-bindings: iio: adc: Add ltc2378 Marcelo Schmitt
2026-06-25 14:43   ` sashiko-bot
2026-06-25 14:35 ` [PATCH v4 2/4] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs Marcelo Schmitt
2026-06-25 14:47   ` sashiko-bot
2026-06-27 21:24   ` David Lechner
2026-06-29 14:57     ` Marcelo Schmitt [this message]
2026-06-29 15:16       ` David Lechner
2026-06-29 16:11         ` Andy Shevchenko
2026-06-29 17:46           ` Marcelo Schmitt
2026-06-25 14:35 ` [PATCH v4 3/4] iio: adc: ltc2378: Enable high-speed data capture Marcelo Schmitt
2026-06-25 14:52   ` sashiko-bot
2026-06-29  5:49   ` Andy Shevchenko
2026-06-29 17:25     ` Marcelo Schmitt
2026-06-29 17:38       ` Andy Shevchenko
2026-06-25 14:35 ` [PATCH v4 4/4] iio: adc: ltc2378: Enable triggered buffer " Marcelo Schmitt
2026-06-25 15:00   ` sashiko-bot
2026-06-29  5:56   ` Andy Shevchenko
2026-06-27 21:39 ` [PATCH v4 0/4] iio: adc: Add support for LTC2378 and similar ADCs David Lechner
2026-07-01 20:32   ` 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=akKHv7j22P6KczXb@debian-BULLSEYE-live-builder-AMD64 \
    --to=marcelo.schmitt1@gmail.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=julianbraha@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@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