Skip to content

Commit 9c0d6cc

Browse files
sknseanjic23
authored andcommitted
iio: adc: stm32-adc: skip adc-diff-channels setup if none is present
If no adc differential channels are defined driver will fail with EINVAL: stm32-adc: probe of 48003000.adc:adc@0 failed with error -22 Fix this by skipping the initialization if no channels are defined. This applies only to the legacy way of initializing adc channels. Fixes: d7705f3 ("iio: adc: stm32-adc: convert to device properties") Signed-off-by: Sean Nyekjaer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent e55245d commit 9c0d6cc

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

drivers/iio/adc/stm32-adc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,16 +2006,15 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
20062006
* to get the *real* number of channels.
20072007
*/
20082008
ret = device_property_count_u32(dev, "st,adc-diff-channels");
2009-
if (ret < 0)
2010-
return ret;
2011-
2012-
ret /= (int)(sizeof(struct stm32_adc_diff_channel) / sizeof(u32));
2013-
if (ret > adc_info->max_channels) {
2014-
dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
2015-
return -EINVAL;
2016-
} else if (ret > 0) {
2017-
adc->num_diff = ret;
2018-
num_channels += ret;
2009+
if (ret > 0) {
2010+
ret /= (int)(sizeof(struct stm32_adc_diff_channel) / sizeof(u32));
2011+
if (ret > adc_info->max_channels) {
2012+
dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
2013+
return -EINVAL;
2014+
} else if (ret > 0) {
2015+
adc->num_diff = ret;
2016+
num_channels += ret;
2017+
}
20192018
}
20202019

20212020
/* Optional sample time is provided either for each, or all channels */

0 commit comments

Comments
 (0)