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

iio: inkern: add out of range error message

If the DT contains an invalid channel specifier then the probe of
iio_hwmon fails with the following message:

iio_hwmon: probe of iio_hwmon failed with error -22

So it's better to print out the relevant channel specifier in
error case to locate the problem.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Stefan Wahren and committed by
Jonathan Cameron
1f202725 4193c0f1

+4 -1
+4 -1
drivers/iio/inkern.c
··· 116 116 if (!iiospec->args_count) 117 117 return 0; 118 118 119 - if (iiospec->args[0] >= indio_dev->num_channels) 119 + if (iiospec->args[0] >= indio_dev->num_channels) { 120 + dev_err(&indio_dev->dev, "invalid channel index %u\n", 121 + iiospec->args[0]); 120 122 return -EINVAL; 123 + } 121 124 122 125 return iiospec->args[0]; 123 126 }