Re: [PATCH v2 3/3] iio: adc: ltc2497: add LTC2493 support
From: Nuno Sá
Date: Thu Oct 22 2026 - 06:37:28 EST
On Thu, 22 Oct 2026 12:58:20 +0300, Andrei Stancovici <andrei.stancovici@xxxxxxxxxx> wrote:
> diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
> index c218d87d3a62..9346a39968d0 100644
> --- a/drivers/iio/adc/ltc2497-core.c
> +++ b/drivers/iio/adc/ltc2497-core.c
> @@ -420,6 +420,49 @@ static const struct iio_chan_spec _name[] = { \
> [ ... skip 39 lines ... ]
> + .num_inputs = 16,
> + .num_channels = ARRAY_SIZE(ltc2497core_channel),
> + .channels = ltc2497core_channel,
> + .channels_samp_freq = ltc2497core_channel_samp_freq,
> + },
> +};
Instead of an array, make this a per supported device variable and see
below.
> @@ -441,17 +485,25 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev)
> else
> indio_dev->name = dev_name(dev);
>
> + for (unsigned int i = 0; i < ARRAY_SIZE(ltc2497core_channel_sets); i++) {
> + if (ltc2497core_channel_sets[i].num_inputs ==
> + ddata->chip_info->num_inputs) {
> + set = <c2497core_channel_sets[i];
> + break;
> + }
> + }
Instead of this lookup why not assigning a channel_set pointer directly
to chip_info? This also looks a very fragile on future additions.
And note that in this case, adding this channel_set mecahism can very
well be a preparatory patch making room for the new device being
supported. Otherwise it's a bit weird having changes in the other
devices chip entries on the patch supporting the new one.
Then, the patch for the new device will be trivial if I'm not missing
nothing.
- Nuno Sá
--
Nuno Sá <nuno.sa@xxxxxxxxxx>