iio: adc: stm32: fix bad error check on max_channels
authorFabrice Gasnier <fabrice.gasnier@st.com>
Mon, 18 Sep 2017 16:24:15 +0000 (18:24 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 24 Sep 2017 13:07:28 +0000 (14:07 +0100)
Fix a bad error check when counting 'st,adc-channels' array elements.
This is seen when all channels are in use simultaneously.

Fixes: 64ad7f643 ("iio: adc: stm32: introduce compatible data cfg")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/stm32-adc.c

index 6bc6028..e93244b 100644 (file)
@@ -1656,7 +1656,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev)
 
        num_channels = of_property_count_u32_elems(node, "st,adc-channels");
        if (num_channels < 0 ||
-           num_channels >= adc_info->max_channels) {
+           num_channels > adc_info->max_channels) {
                dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
                return num_channels < 0 ? num_channels : -EINVAL;
        }