diff mbox series

[5/7] iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request then disable

Message ID 20210402184544.488862-6-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>

This new flag cleanly avoids the need for a dance where we request the
interrupt only to immediately disabling it by ensuring it is not
auto-enabled in the first place.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
---
 drivers/iio/chemical/scd30_core.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Song Bao Hua (Barry Song) April 2, 2021, 8:14 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>; Tomasz Duszynski
> <tomasz.duszynski@octakon.com>
> Subject: [PATCH 5/7] iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request
> then disable
> 
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This new flag cleanly avoids the need for a dance where we request the
> interrupt only to immediately disabling it by ensuring it is not
> auto-enabled in the first place.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
> ---

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

>  drivers/iio/chemical/scd30_core.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/chemical/scd30_core.c
> b/drivers/iio/chemical/scd30_core.c
> index 261c277ac4a5..d89f117dd0ef 100644
> --- a/drivers/iio/chemical/scd30_core.c
> +++ b/drivers/iio/chemical/scd30_core.c
> @@ -655,19 +655,19 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
> 
>  	indio_dev->trig = iio_trigger_get(trig);
> 
> +	/*
> +	 * Interrupt is enabled just before taking a fresh measurement
> +	 * and disabled afterwards. This means we need to ensure it is not
> +	 * enabled here to keep calls to enable/disable balanced.
> +	 */
>  	ret = devm_request_threaded_irq(dev, state->irq, scd30_irq_handler,
> -					scd30_irq_thread_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +					scd30_irq_thread_handler,
> +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
> +					IRQF_NO_AUTOEN,
>  					indio_dev->name, indio_dev);
>  	if (ret)
>  		dev_err(dev, "failed to request irq\n");
> 
> -	/*
> -	 * Interrupt is enabled just before taking a fresh measurement
> -	 * and disabled afterwards. This means we need to disable it here
> -	 * to keep calls to enable/disable balanced.
> -	 */
> -	disable_irq(state->irq);
> -
>  	return ret;
>  }
> 
> --
> 2.31.1
Jonathan Cameron April 5, 2021, 2:36 p.m. UTC | #2
On Fri, 2 Apr 2021 20:14:04 +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>; Tomasz Duszynski
> > <tomasz.duszynski@octakon.com>
> > Subject: [PATCH 5/7] iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request
> > then disable
> > 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > This new flag cleanly avoids the need for a dance where we request the
> > interrupt only to immediately disabling it by ensuring it is not
> > auto-enabled in the first place.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
> > ---  
> 
> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to poke at it.  Whilst they are doing that, any
additional feedback welcomed.

Thanks,

Jonathan

> 
> >  drivers/iio/chemical/scd30_core.c | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/iio/chemical/scd30_core.c
> > b/drivers/iio/chemical/scd30_core.c
> > index 261c277ac4a5..d89f117dd0ef 100644
> > --- a/drivers/iio/chemical/scd30_core.c
> > +++ b/drivers/iio/chemical/scd30_core.c
> > @@ -655,19 +655,19 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
> > 
> >  	indio_dev->trig = iio_trigger_get(trig);
> > 
> > +	/*
> > +	 * Interrupt is enabled just before taking a fresh measurement
> > +	 * and disabled afterwards. This means we need to ensure it is not
> > +	 * enabled here to keep calls to enable/disable balanced.
> > +	 */
> >  	ret = devm_request_threaded_irq(dev, state->irq, scd30_irq_handler,
> > -					scd30_irq_thread_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> > +					scd30_irq_thread_handler,
> > +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
> > +					IRQF_NO_AUTOEN,
> >  					indio_dev->name, indio_dev);
> >  	if (ret)
> >  		dev_err(dev, "failed to request irq\n");
> > 
> > -	/*
> > -	 * Interrupt is enabled just before taking a fresh measurement
> > -	 * and disabled afterwards. This means we need to disable it here
> > -	 * to keep calls to enable/disable balanced.
> > -	 */
> > -	disable_irq(state->irq);
> > -
> >  	return ret;
> >  }
> > 
> > --
> > 2.31.1  
>
diff mbox series

Patch

diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
index 261c277ac4a5..d89f117dd0ef 100644
--- a/drivers/iio/chemical/scd30_core.c
+++ b/drivers/iio/chemical/scd30_core.c
@@ -655,19 +655,19 @@  static int scd30_setup_trigger(struct iio_dev *indio_dev)
 
 	indio_dev->trig = iio_trigger_get(trig);
 
+	/*
+	 * Interrupt is enabled just before taking a fresh measurement
+	 * and disabled afterwards. This means we need to ensure it is not
+	 * enabled here to keep calls to enable/disable balanced.
+	 */
 	ret = devm_request_threaded_irq(dev, state->irq, scd30_irq_handler,
-					scd30_irq_thread_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+					scd30_irq_thread_handler,
+					IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
+					IRQF_NO_AUTOEN,
 					indio_dev->name, indio_dev);
 	if (ret)
 		dev_err(dev, "failed to request irq\n");
 
-	/*
-	 * Interrupt is enabled just before taking a fresh measurement
-	 * and disabled afterwards. This means we need to disable it here
-	 * to keep calls to enable/disable balanced.
-	 */
-	disable_irq(state->irq);
-
 	return ret;
 }