linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Alexandru Ardelean <ardeleanalex@gmail.com>,
	"tiantao (H)" <tiantao6@hisilicon.com>
Subject: Re: [PATCH 7/7] iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than request and disable
Date: Mon, 5 Apr 2021 15:51:52 +0100	[thread overview]
Message-ID: <20210405155152.14abf3dc@jic23-huawei> (raw)
In-Reply-To: <b63838854fee434aa96cd54c13014b51@hisilicon.com>

On Fri, 2 Apr 2021 20:30:17 +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>;
> > Alexandru Ardelean <ardeleanalex@gmail.com>
> > Subject: [PATCH 7/7] iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than
> > request and disable
> > 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > These devices are not able to mask the signal used as a data ready
> > interrupt.  As such they previously requested the irq then immediately
> > disabled it.  Now we can avoid the potential of a spurious interrupt
> > by avoiding the irq being auto enabled in the first place.
> > 
> > I'm not sure how this code could have been called with the irq already
> > disabled, so I believe the conditional would always have been true and
> > have removed it.
> >   
> 
> If irq_dis is true, it seems the original code assumed interrupt was
> open. Now the code is moving to disable-irq for true irq_dis. For
> false irq_dis, this patch has no side effect so looks correct.
Hi Barry,

As far as I can tell (and I looked closely :), at the point where
ad_sd_probe_trigger() can be called, irq_dis is always false,
so the original check is misleading by implying
otherwise.

Taken in isolation of what is visible in this patch I'd agree
the change you suggest makes sense, but I'd also like to clean
up the wrong impression the original check was giving.  It is
also worth noting that ad_sigma_delta.h lists irq_dis as a
private member of the structure that should only be used in the
library (reducing chances of any drivers in future doing something
odd with it).

The other checks on irq_dis look suspicious as well, but removing
those would rather spread the scope of this patch.

As Lars has given an Reviewed-by and this is his code, I'm going
to press ahead with this as it stands.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to see if we missed anything.

Thanks,

Jonathan

> 
> A safer way might be as below?
> 
> if(!sigma_delta->irq_dis)
> 	irq_flags = sigma_delta->info->irq_flags | IRQF_NO_AUTOEN;
> 
> request_irq(irq_flags);
> 
> sigma_delta->irq_dis =  true;
> 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Lars-Peter Clausen <lars@metafoo.de>
> > Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
> > ---
> >  drivers/iio/adc/ad_sigma_delta.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ad_sigma_delta.c
> > b/drivers/iio/adc/ad_sigma_delta.c
> > index 9289812c0a94..e777ec718973 100644
> > --- a/drivers/iio/adc/ad_sigma_delta.c
> > +++ b/drivers/iio/adc/ad_sigma_delta.c
> > @@ -485,18 +485,15 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
> >  	sigma_delta->trig->ops = &ad_sd_trigger_ops;
> >  	init_completion(&sigma_delta->completion);
> > 
> > +	sigma_delta->irq_dis = true;
> >  	ret = request_irq(sigma_delta->spi->irq,
> >  			  ad_sd_data_rdy_trig_poll,
> > -			  sigma_delta->info->irq_flags,
> > +			  sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
> >  			  indio_dev->name,
> >  			  sigma_delta);
> >  	if (ret)
> >  		goto error_free_trig;
> > 
> > -	if (!sigma_delta->irq_dis) {
> > -		sigma_delta->irq_dis = true;
> > -		disable_irq_nosync(sigma_delta->spi->irq);
> > -	}
> >  	iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta);
> > 
> >  	ret = iio_trigger_register(sigma_delta->trig);
> > --
> > 2.31.1  
> 
> Thanks
> Barry
> 


  reply	other threads:[~2021-04-05 14:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 18:45 [PATCH 0/7] iio: Use IRQF_NO_AUTOEN Jonathan Cameron
2021-04-02 18:45 ` [PATCH 1/7] iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce boilerplate Jonathan Cameron
2021-04-02 20:10   ` Song Bao Hua (Barry Song)
2021-04-05 14:27     ` Jonathan Cameron
2021-04-02 18:45 ` [PATCH 2/7] iio:adc:exynos-adc: Use new IRQF_NO_AUTOEN flag rather than separate irq_disable() Jonathan Cameron
2021-04-02 20:11   ` Song Bao Hua (Barry Song)
2021-04-04 19:20   ` Krzysztof Kozlowski
2021-04-05 14:29     ` Jonathan Cameron
2021-04-02 18:45 ` [PATCH 3/7] iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request then disable Jonathan Cameron
2021-04-02 20:12   ` Song Bao Hua (Barry Song)
2021-04-05 14:33     ` Jonathan Cameron
2021-04-02 18:45 ` [PATCH 4/7] iio:adc:sun4i-gpadc: Use new IRQF_NO_AUTOEN flag " Jonathan Cameron
2021-04-02 20:13   ` Song Bao Hua (Barry Song)
2021-04-05 14:35     ` Jonathan Cameron
2021-04-02 18:45 ` [PATCH 5/7] iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq " Jonathan Cameron
2021-04-02 20:14   ` Song Bao Hua (Barry Song)
2021-04-05 14:36     ` Jonathan Cameron
2021-04-02 18:45 ` [PATCH 6/7] iio:imu:adis: Use IRQF_NO_AUTOEN instead of " Jonathan Cameron
2021-04-02 20:37   ` Song Bao Hua (Barry Song)
2021-04-05 14:40     ` Jonathan Cameron
2021-04-06 11:48       ` Sa, Nuno
2021-04-02 18:45 ` [PATCH 7/7] iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than request and disable Jonathan Cameron
2021-04-02 20:30   ` Song Bao Hua (Barry Song)
2021-04-05 14:51     ` Jonathan Cameron [this message]
2021-04-05 22:56       ` Song Bao Hua (Barry Song)
2021-04-02 19:00 ` [PATCH 0/7] iio: Use IRQF_NO_AUTOEN Andy Shevchenko
2021-04-03 11:45 ` Lars-Peter Clausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210405155152.14abf3dc@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=ardeleanalex@gmail.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=song.bao.hua@hisilicon.com \
    --cc=tiantao6@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).