diff mbox series

[3/7] iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request then disable

Message ID 20210402184544.488862-4-jic23@kernel.org (mailing list archive)
State New
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>

Whilst a race during interrupt enabling is probably not a problem,
it is better to not enable the interrupt at all.  The new
IRQF_NO_AUTOEN flag allows us to do that.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/iio/adc/nau7802.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Song Bao Hua (Barry Song) April 2, 2021, 8:12 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>; Alexandre Belloni
> <alexandre.belloni@bootlin.com>
> Subject: [PATCH 3/7] iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request
> then disable
> 
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Whilst a race during interrupt enabling is probably not a problem,
> it is better to not enable the interrupt at all.  The new
> IRQF_NO_AUTOEN flag allows us to do that.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---

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

>  drivers/iio/adc/nau7802.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
> index 07c85434b568..bb70b51d25b1 100644
> --- a/drivers/iio/adc/nau7802.c
> +++ b/drivers/iio/adc/nau7802.c
> @@ -498,7 +498,8 @@ static int nau7802_probe(struct i2c_client *client,
>  		ret = request_threaded_irq(client->irq,
>  				NULL,
>  				nau7802_eoc_trigger,
> -				IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +				IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
> +				IRQF_NO_AUTOEN,
>  				client->dev.driver->name,
>  				indio_dev);
>  		if (ret) {
> @@ -513,8 +514,7 @@ static int nau7802_probe(struct i2c_client *client,
>  			dev_info(&client->dev,
>  				"Failed to allocate IRQ, using polling mode\n");
>  			client->irq = 0;
> -		} else
> -			disable_irq(client->irq);
> +		}
>  	}
> 
>  	if (!client->irq) {
> --
> 2.31.1
Jonathan Cameron April 5, 2021, 2:33 p.m. UTC | #2
On Fri, 2 Apr 2021 20:12:13 +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>; Alexandre Belloni
> > <alexandre.belloni@bootlin.com>
> > Subject: [PATCH 3/7] iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request
> > then disable
> > 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Whilst a race during interrupt enabling is probably not a problem,
> > it is better to not enable the interrupt at all.  The new
> > IRQF_NO_AUTOEN flag allows us to do that.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > ---  
> 
> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Applied and pushed out as testing to let the autobuilders test it a bit.
Still time for others to respond though as I can rebase for at least the
next few days as I expect I'll do a pull request mid week.

Thanks,

Jonathan

> 
> >  drivers/iio/adc/nau7802.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
> > index 07c85434b568..bb70b51d25b1 100644
> > --- a/drivers/iio/adc/nau7802.c
> > +++ b/drivers/iio/adc/nau7802.c
> > @@ -498,7 +498,8 @@ static int nau7802_probe(struct i2c_client *client,
> >  		ret = request_threaded_irq(client->irq,
> >  				NULL,
> >  				nau7802_eoc_trigger,
> > -				IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> > +				IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
> > +				IRQF_NO_AUTOEN,
> >  				client->dev.driver->name,
> >  				indio_dev);
> >  		if (ret) {
> > @@ -513,8 +514,7 @@ static int nau7802_probe(struct i2c_client *client,
> >  			dev_info(&client->dev,
> >  				"Failed to allocate IRQ, using polling mode\n");
> >  			client->irq = 0;
> > -		} else
> > -			disable_irq(client->irq);
> > +		}
> >  	}
> > 
> >  	if (!client->irq) {
> > --
> > 2.31.1  
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index 07c85434b568..bb70b51d25b1 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -498,7 +498,8 @@  static int nau7802_probe(struct i2c_client *client,
 		ret = request_threaded_irq(client->irq,
 				NULL,
 				nau7802_eoc_trigger,
-				IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+				IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
+				IRQF_NO_AUTOEN,
 				client->dev.driver->name,
 				indio_dev);
 		if (ret) {
@@ -513,8 +514,7 @@  static int nau7802_probe(struct i2c_client *client,
 			dev_info(&client->dev,
 				"Failed to allocate IRQ, using polling mode\n");
 			client->irq = 0;
-		} else
-			disable_irq(client->irq);
+		}
 	}
 
 	if (!client->irq) {