diff mbox series

[2/2] iio: ad7768-1: Call iio_trigger_notify_done() on error

Message ID 20211101144055.13858-2-lars@metafoo.de (mailing list archive)
State Accepted
Headers show
Series [1/2] iio: itg3200: Call iio_trigger_notify_done() on error | expand

Commit Message

Lars-Peter Clausen Nov. 1, 2021, 2:40 p.m. UTC
IIO trigger handlers must call iio_trigger_notify_done() when done. This
must be done even when an error occurred. Otherwise the trigger will be
seen as busy indefinitely and the trigger handler will never be called
again.

The ad7768-1 driver neglects to call iio_trigger_notify_done() when there
is an error reading the converter data. Fix this by making sure that
iio_trigger_notify_done() is included in the error exit path.

Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7768-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron Nov. 13, 2021, 4:28 p.m. UTC | #1
On Mon,  1 Nov 2021 15:40:55 +0100
Lars-Peter Clausen <lars@metafoo.de> wrote:

> IIO trigger handlers must call iio_trigger_notify_done() when done. This
> must be done even when an error occurred. Otherwise the trigger will be
> seen as busy indefinitely and the trigger handler will never be called
> again.
> 
> The ad7768-1 driver neglects to call iio_trigger_notify_done() when there
> is an error reading the converter data. Fix this by making sure that
> iio_trigger_notify_done() is included in the error exit path.
> 
> Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Hi Lars,

I've always meant to have a hard think about what we 'should' do in the event
of an error in one of these trigger handlers.   Definitely don't want to get
stuck so these patches make sense, but I'd also at somepoint like to explore
if we should stop the device capture and do something like poison the kfifo
output so that we know it was broken. 

Anyhow, a discussion for another day.

Applied these two to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7768-1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index 2c5c8a3672b2..aa42ba759fa1 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> @@ -480,8 +480,8 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
>  	iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
>  					   iio_get_time_ns(indio_dev));
>  
> -	iio_trigger_notify_done(indio_dev->trig);
>  err_unlock:
> +	iio_trigger_notify_done(indio_dev->trig);
>  	mutex_unlock(&st->lock);
>  
>  	return IRQ_HANDLED;
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
index 2c5c8a3672b2..aa42ba759fa1 100644
--- a/drivers/iio/adc/ad7768-1.c
+++ b/drivers/iio/adc/ad7768-1.c
@@ -480,8 +480,8 @@  static irqreturn_t ad7768_trigger_handler(int irq, void *p)
 	iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
 					   iio_get_time_ns(indio_dev));
 
-	iio_trigger_notify_done(indio_dev->trig);
 err_unlock:
+	iio_trigger_notify_done(indio_dev->trig);
 	mutex_unlock(&st->lock);
 
 	return IRQ_HANDLED;