Re: [PATCH v4 2/4] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs

From: David Lechner

Date: Mon Jun 29 2026 - 11:23:24 EST


It helps if you don't trim the "On ... wrote:" part of the reply so that
we know who wrote what. :-)


On 6/29/26 9:57 AM, Marcelo Schmitt wrote:
>>> +{ \
>>> + .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.
>

It could use `_offl ? ...` in the macro for that. Not a big deal to me though.

>>> +
>>> +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?

The if returns unconditionally, so else is not needed. This is just a general
principal.