diff mbox series

[1/8] iio: adc: stm32-adc: fix channel sampling time init

Message ID 20220928164114.48339-2-olivier.moysan@foss.st.com (mailing list archive)
State Changes Requested
Headers show
Series iio: stm32-adc: add support of adc for stm32mp13 | expand

Commit Message

Olivier Moysan Sept. 28, 2022, 4:41 p.m. UTC
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: 796e5d0b1e9b ("iio: adc: stm32-adc: use generic binding for sample-time")

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
 drivers/iio/adc/stm32-adc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Andy Shevchenko Sept. 28, 2022, 4:51 p.m. UTC | #1
On Wed, Sep 28, 2022 at 7:42 PM Olivier Moysan
<olivier.moysan@foss.st.com> wrote:
>
> 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.

What is the text width here? It's okay to use Up to ~72 (or slightly
more) as a limit and format accordingly.

> Fixes: 796e5d0b1e9b ("iio: adc: stm32-adc: use generic binding for sample-time")
>
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>

Tag blocks mustn't have the blank lines.
Jonathan Cameron Oct. 2, 2022, 1:33 p.m. UTC | #2
On Wed, 28 Sep 2022 19:51:04 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Sep 28, 2022 at 7:42 PM Olivier Moysan
> <olivier.moysan@foss.st.com> wrote:
> >
> > 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.  
> 
> What is the text width here? It's okay to use Up to ~72 (or slightly
> more) as a limit and format accordingly.
> 
> > Fixes: 796e5d0b1e9b ("iio: adc: stm32-adc: use generic binding for sample-time")
> >
> > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>  
> 
> Tag blocks mustn't have the blank lines.
> 
For this one, please make it clear if this is breaking current systems
or if this is more theoretical, so I can judge whether to rush it in (and
potentially slow down the rest of this patch set!)

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 6256977eb7f7..3cda529f081d 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -2086,18 +2086,19 @@  static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
 					vin[1], scan_index, differential);
 
+		val = 0;
 		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
 		/* st,min-sample-time-ns is optional */
-		if (!ret) {
-			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
-			if (differential)
-				stm32_adc_smpr_init(adc, vin[1], val);
-		} else if (ret != -EINVAL) {
+		if (ret && ret != -EINVAL) {
 			dev_err(&indio_dev->dev, "Invalid st,min-sample-time-ns property %d\n",
 				ret);
 			goto err;
 		}
 
+		stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
+		if (differential)
+			stm32_adc_smpr_init(adc, vin[1], val);
+
 		scan_index++;
 	}