Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7124: Don't create more channels than the driver can handle

The ad7124-4 and ad7124-8 both support 16 channel registers and assigns
each channel defined in dt statically such a register. While the driver
could be a bit more clever about this, it currently isn't and specifying
more than 16 channels yields broken behaviour. So just refuse to bind in
this situation.

Fixes: b3af341bbd96 ("iio: adc: Add ad7124 support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/1b9a5a1d334e5501294f7f9f9d5893f1cdf1b0ec.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Uwe Kleine-König and committed by
Jonathan Cameron
cc597af1 645fb7c2

+10
+10
drivers/iio/adc/ad7124.c
··· 821 821 if (!st->num_channels) 822 822 return dev_err_probe(dev, -ENODEV, "no channel children\n"); 823 823 824 + /* 825 + * The driver assigns each logical channel defined in the device tree 826 + * statically one channel register. So only accept 16 such logical 827 + * channels to not treat CONFIG_0 (i.e. the register following 828 + * CHANNEL_15) as an additional channel register. The driver could be 829 + * improved to lift this limitation. 830 + */ 831 + if (st->num_channels > AD7124_MAX_CHANNELS) 832 + return dev_err_probe(dev, -EINVAL, "Too many channels defined\n"); 833 + 824 834 chan = devm_kcalloc(indio_dev->dev.parent, st->num_channels, 825 835 sizeof(*chan), GFP_KERNEL); 826 836 if (!chan)