On Fri, 2024-11-08 at 19:18 +0100, Uwe Kleine-König wrote: > The ad7124-4 and ad7124-8 both support 16 channel registers. Don't > accept more (logical) channels from dt than that. > > Fixes: b3af341bbd96 ("iio: adc: Add ad7124 support") > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx> > --- > drivers/iio/adc/ad7124.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c > index a5d91933f505..7473bcef7bc6 100644 > --- a/drivers/iio/adc/ad7124.c > +++ b/drivers/iio/adc/ad7124.c > @@ -18,6 +18,7 @@ > #include <linux/property.h> > #include <linux/regulator/consumer.h> > #include <linux/spi/spi.h> > +#include <linux/stringify.h> > > #include <linux/iio/iio.h> > #include <linux/iio/adc/ad_sigma_delta.h> > @@ -821,6 +822,11 @@ static int ad7124_parse_channel_config(struct iio_dev > *indio_dev, > if (!st->num_channels) > return dev_err_probe(dev, -ENODEV, "no channel children\n"); > > + if (st->num_channels > AD7124_MAX_CHANNELS) { > + dev_warn(dev, "Limit number of channels to " > __stringify(AD7124_MAX_CHANNELS) "\n"); > + st->num_channels = AD7124_MAX_CHANNELS; > + } Hmmm, I would treat it as an error... - Nuno Sá