Skip to content

Commit 174dac5

Browse files
Olivier Moysanjic23
authored andcommitted
iio: adc: stm32-adc: fix channel sampling time init
Fix channel init for ADC generic channel bindings. In generic channel initialization, stm32_adc_smpr_init() is called to initialize channel sampling time. The "st,min-sample-time-ns" property is an optional property. If it is not defined, stm32_adc_smpr_init() is currently skipped. However stm32_adc_smpr_init() must always be called, to force a minimum sampling time for the internal channels, as the minimum sampling time is known. Make stm32_adc_smpr_init() call unconditional. Fixes: 796e5d0 ("iio: adc: stm32-adc: use generic binding for sample-time") Signed-off-by: Olivier Moysan <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Fabrice Gasnier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent aa6c77d commit 174dac5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/iio/adc/stm32-adc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,18 +2086,19 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
20862086
stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
20872087
vin[1], scan_index, differential);
20882088

2089+
val = 0;
20892090
ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
20902091
/* st,min-sample-time-ns is optional */
2091-
if (!ret) {
2092-
stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
2093-
if (differential)
2094-
stm32_adc_smpr_init(adc, vin[1], val);
2095-
} else if (ret != -EINVAL) {
2092+
if (ret && ret != -EINVAL) {
20962093
dev_err(&indio_dev->dev, "Invalid st,min-sample-time-ns property %d\n",
20972094
ret);
20982095
goto err;
20992096
}
21002097

2098+
stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
2099+
if (differential)
2100+
stm32_adc_smpr_init(adc, vin[1], val);
2101+
21012102
scan_index++;
21022103
}
21032104

0 commit comments

Comments
 (0)