diff mbox series

[v4,8/8] iio: adc: ad7606: Disable PWM usage for non backend version

Message ID 20241009-ad7606_add_iio_backend_support-v4-8-6971a8c0f1d5@baylibre.com (mailing list archive)
State Not Applicable
Headers show
Series Add iio backend compatibility for ad7606 | expand

Commit Message

Guillaume Stols Oct. 9, 2024, 9:19 a.m. UTC
Since the pwm was introduced before backend, there was a mock use, with
a GPIO emulation. Now that iio backend is introduced, the mock use can
be removed.

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
---
 drivers/iio/adc/ad7606.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Nuno Sá Oct. 9, 2024, 2:45 p.m. UTC | #1
On Wed, 2024-10-09 at 09:19 +0000, Guillaume Stols wrote:
> Since the pwm was introduced before backend, there was a mock use, with
> a GPIO emulation. Now that iio backend is introduced, the mock use can
> be removed.
> 
> Signed-off-by: Guillaume Stols <gstols@baylibre.com>
> ---

Maybe this was agreed on the previous iterations but I wonder if we shouldn't just
bring PWM support in the same patch as backend support is added...

- Nuno Sá
Jonathan Cameron Oct. 12, 2024, 12:48 p.m. UTC | #2
On Wed, 09 Oct 2024 16:45:40 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Wed, 2024-10-09 at 09:19 +0000, Guillaume Stols wrote:
> > Since the pwm was introduced before backend, there was a mock use, with
> > a GPIO emulation. Now that iio backend is introduced, the mock use can
> > be removed.
> > 
> > Signed-off-by: Guillaume Stols <gstols@baylibre.com>
> > ---  
> 
> Maybe this was agreed on the previous iterations but I wonder if we shouldn't just
> bring PWM support in the same patch as backend support is added...
> 

I can't remember why we ended up in this position (might have been me
who asked for it!) but I'm fine with the logical steps we have in the
series, and it will all merge together. So probably not worth rethinking
now!

I took another look and other than the stuff Nuno has raised this series
looks good to me.

Figures crossed for v5 :)

Jonathan


> - Nuno Sá
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 1313b5cbb0aa..a117206e5256 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -473,8 +473,6 @@  static int ad7606_pwm_set_high(struct ad7606_state *st)
 	cnvst_pwm_state.duty_cycle = cnvst_pwm_state.period;
 
 	ret = pwm_apply_might_sleep(st->cnvst_pwm, &cnvst_pwm_state);
-	/* sleep 2 µS to let finish the current pulse */
-	fsleep(2);
 
 	return ret;
 }
@@ -492,8 +490,6 @@  static int ad7606_pwm_set_low(struct ad7606_state *st)
 	cnvst_pwm_state.duty_cycle = 0;
 
 	ret = pwm_apply_might_sleep(st->cnvst_pwm, &cnvst_pwm_state);
-	/* sleep 2 µS to let finish the current pulse */
-	fsleep(2);
 
 	return ret;
 }
@@ -576,7 +572,6 @@  static irqreturn_t ad7606_trigger_handler(int irq, void *p)
 	iio_trigger_notify_done(indio_dev->trig);
 	/* The rising edge of the CONVST signal starts a new conversion. */
 	gpiod_set_value(st->gpio_convst, 1);
-	ad7606_pwm_set_high(st);
 
 	return IRQ_HANDLED;
 }
@@ -899,7 +894,6 @@  static int ad7606_buffer_postenable(struct iio_dev *indio_dev)
 	struct ad7606_state *st = iio_priv(indio_dev);
 
 	gpiod_set_value(st->gpio_convst, 1);
-	ad7606_pwm_set_high(st);
 
 	return 0;
 }
@@ -909,7 +903,6 @@  static int ad7606_buffer_predisable(struct iio_dev *indio_dev)
 	struct ad7606_state *st = iio_priv(indio_dev);
 
 	gpiod_set_value(st->gpio_convst, 0);
-	ad7606_pwm_set_low(st);
 
 	return 0;
 }
@@ -1204,6 +1197,12 @@  int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
 
 		indio_dev->setup_ops = &ad7606_pwm_buffer_ops;
 	} else {
+
+		/* Reserve the PWM use only for backend (force gpio_convst definition) */
+		if (!st->gpio_convst)
+			return dev_err_probe(dev, -EINVAL,
+					     "No backend, connect convst to a GPIO");
+
 		init_completion(&st->completion);
 		st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
 						  indio_dev->name,