diff mbox series

[1/7] iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce boilerplate

Message ID 20210402184544.488862-2-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series iio: Use IRQF_NO_AUTOEN | expand

Commit Message

Jonathan Cameron April 2, 2021, 6:45 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As iio_poll_trigger() is safe against spurious interrupts when the
trigger is not enabled, this is not a fix despite looking like
a race.  It is nice to simplify the code however so the interrupt
is never enabled in the first place.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7766.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

Song Bao Hua (Barry Song) April 2, 2021, 8:10 p.m. UTC | #1
> -----Original Message-----
> From: Jonathan Cameron [mailto:jic23@kernel.org]
> Sent: Saturday, April 3, 2021 7:46 AM
> To: linux-iio@vger.kernel.org
> Cc: Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com>; Jonathan Cameron
> <jonathan.cameron@huawei.com>; Lars-Peter Clausen <lars@metafoo.de>
> Subject: [PATCH 1/7] iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce
> boilerplate
> 
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> As iio_poll_trigger() is safe against spurious interrupts when the
> trigger is not enabled, this is not a fix despite looking like
> a race.  It is nice to simplify the code however so the interrupt
> is never enabled in the first place.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> ---

Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>

BTW, +Cc Tiantao as Tao might be moving drivers to
use IRQF_NO_AUTOEN.


>  drivers/iio/adc/ad7766.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
> index 829a3426f235..1e41759f3ee5 100644
> --- a/drivers/iio/adc/ad7766.c
> +++ b/drivers/iio/adc/ad7766.c
> @@ -255,18 +255,17 @@ static int ad7766_probe(struct spi_device *spi)
>  		ad7766->trig->ops = &ad7766_trigger_ops;
>  		iio_trigger_set_drvdata(ad7766->trig, ad7766);
> 
> -		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> -			IRQF_TRIGGER_FALLING, dev_name(&spi->dev),
> -			ad7766->trig);
> -		if (ret < 0)
> -			return ret;
> -
>  		/*
>  		 * The device generates interrupts as long as it is powered up.
>  		 * Some platforms might not allow the option to power it down so
> -		 * disable the interrupt to avoid extra load on the system
> +		 * don't enable the interrupt to avoid extra load on the system
>  		 */
> -		disable_irq(spi->irq);
> +		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> +				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
> +				       dev_name(&spi->dev),
> +				       ad7766->trig);
> +		if (ret < 0)
> +			return ret;
> 
>  		ret = devm_iio_trigger_register(&spi->dev, ad7766->trig);
>  		if (ret)
> --
> 2.31.1
Jonathan Cameron April 5, 2021, 2:27 p.m. UTC | #2
On Fri, 2 Apr 2021 20:10:38 +0000
"Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com> wrote:

> > -----Original Message-----
> > From: Jonathan Cameron [mailto:jic23@kernel.org]
> > Sent: Saturday, April 3, 2021 7:46 AM
> > To: linux-iio@vger.kernel.org
> > Cc: Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com>; Jonathan Cameron
> > <jonathan.cameron@huawei.com>; Lars-Peter Clausen <lars@metafoo.de>
> > Subject: [PATCH 1/7] iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce
> > boilerplate
> > 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > As iio_poll_trigger() is safe against spurious interrupts when the
> > trigger is not enabled, this is not a fix despite looking like
> > a race.  It is nice to simplify the code however so the interrupt
> > is never enabled in the first place.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Lars-Peter Clausen <lars@metafoo.de>
> > ---  
> 
> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Applied to the togreg branch of iio.git and pushed out as testing to
let the autobuilders see if they can find anything we missed.

Thanks,

Jonathan

> 
> BTW, +Cc Tiantao as Tao might be moving drivers to
> use IRQF_NO_AUTOEN.
> 
> 
> >  drivers/iio/adc/ad7766.c | 15 +++++++--------
> >  1 file changed, 7 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
> > index 829a3426f235..1e41759f3ee5 100644
> > --- a/drivers/iio/adc/ad7766.c
> > +++ b/drivers/iio/adc/ad7766.c
> > @@ -255,18 +255,17 @@ static int ad7766_probe(struct spi_device *spi)
> >  		ad7766->trig->ops = &ad7766_trigger_ops;
> >  		iio_trigger_set_drvdata(ad7766->trig, ad7766);
> > 
> > -		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> > -			IRQF_TRIGGER_FALLING, dev_name(&spi->dev),
> > -			ad7766->trig);
> > -		if (ret < 0)
> > -			return ret;
> > -
> >  		/*
> >  		 * The device generates interrupts as long as it is powered up.
> >  		 * Some platforms might not allow the option to power it down so
> > -		 * disable the interrupt to avoid extra load on the system
> > +		 * don't enable the interrupt to avoid extra load on the system
> >  		 */
> > -		disable_irq(spi->irq);
> > +		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
> > +				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
> > +				       dev_name(&spi->dev),
> > +				       ad7766->trig);
> > +		if (ret < 0)
> > +			return ret;
> > 
> >  		ret = devm_iio_trigger_register(&spi->dev, ad7766->trig);
> >  		if (ret)
> > --
> > 2.31.1  
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
index 829a3426f235..1e41759f3ee5 100644
--- a/drivers/iio/adc/ad7766.c
+++ b/drivers/iio/adc/ad7766.c
@@ -255,18 +255,17 @@  static int ad7766_probe(struct spi_device *spi)
 		ad7766->trig->ops = &ad7766_trigger_ops;
 		iio_trigger_set_drvdata(ad7766->trig, ad7766);
 
-		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
-			IRQF_TRIGGER_FALLING, dev_name(&spi->dev),
-			ad7766->trig);
-		if (ret < 0)
-			return ret;
-
 		/*
 		 * The device generates interrupts as long as it is powered up.
 		 * Some platforms might not allow the option to power it down so
-		 * disable the interrupt to avoid extra load on the system
+		 * don't enable the interrupt to avoid extra load on the system
 		 */
-		disable_irq(spi->irq);
+		ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
+				       IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
+				       dev_name(&spi->dev),
+				       ad7766->trig);
+		if (ret < 0)
+			return ret;
 
 		ret = devm_iio_trigger_register(&spi->dev, ad7766->trig);
 		if (ret)