[PATCH v3 10/10] iio: adc: ad7606: Disable PWM usage for non backend version
From: Guillaume Stols
Date: Fri Oct 04 2024 - 17:51:15 EST
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@xxxxxxxxxxxx>
---
drivers/iio/adc/ad7606.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index d86eb7c3e4f7..7d02aad45242 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 */
- fleep(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 */
- fleep(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;
}
@@ -900,7 +895,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;
}
@@ -910,7 +904,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 {
init_completion(&st->completion);
+
+ /* 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");
+
st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
indio_dev->name,
iio_device_id(indio_dev));
--
2.34.1