linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Phil Reid <preid@electromag.com.au>, linux-kernel@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v6 19/57] iio: Remove dev_err() usage after platform_get_irq()
Date: Wed, 31 Jul 2019 07:32:12 -0700	[thread overview]
Message-ID: <5d41a66d.1c69fb81.6d372.4c72@mx.google.com> (raw)
In-Reply-To: <f28e8440-a57d-e269-f3a8-5bf5b9fcd41f@electromag.com.au>

Quoting Phil Reid (2019-07-30 23:42:16)
> G'day Stephen,
> 
> A comment unrelated to your change.
> 
> On 31/07/2019 02:15, Stephen Boyd wrote:
> ....
> 
> > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> > index 32f1c4a33b20..abe99856c823 100644
> > --- a/drivers/iio/adc/at91_adc.c
> > +++ b/drivers/iio/adc/at91_adc.c
> > @@ -1179,10 +1179,8 @@ static int at91_adc_probe(struct platform_device *pdev)
> >       idev->info = &at91_adc_info;
> >   
> >       st->irq = platform_get_irq(pdev, 0);
> > -     if (st->irq < 0) {
> > -             dev_err(&pdev->dev, "No IRQ ID is designated\n");
> > +     if (st->irq < 0)
> >               return -ENODEV;
> Should this be returning st->irq instead of -ENODEV?
> eg: platform_get_irq can return -EPROBE_DEFER
> 
> Pattern is repeated in a number of other places.

Probably? Here's a patch.

----8<----
From: Stephen Boyd <swboyd@chromium.org>
Subject: [PATCH] iio: Return error values from platform_get_irq*()

Sometimes platform_get_irq*() can return -EPROBE_DEFER, so it's best to
return the actual error value from calling this function instead of
overriding the value to something like -EINVAL or -ENXIO. Except for in
the case when the irq value is 0 and the driver knows that irq 0 isn't
valid. In such a situation, return whatever error value was returned
before this change.

Reported-by: Phil Reid <preid@electromag.com.au>
Cc: Phil Reid <preid@electromag.com.au>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/iio/adc/at91_adc.c      | 2 +-
 drivers/iio/adc/bcm_iproc_adc.c | 2 +-
 drivers/iio/adc/fsl-imx25-gcq.c | 4 +---
 drivers/iio/adc/lpc32xx_adc.c   | 2 +-
 drivers/iio/adc/npcm_adc.c      | 2 +-
 drivers/iio/adc/spear_adc.c     | 2 +-
 6 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index abe99856c823..2c604198c4b7 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1180,7 +1180,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	st->irq = platform_get_irq(pdev, 0);
 	if (st->irq < 0)
-		return -ENODEV;
+		return st->irq;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 646ebdc0a8b4..6c05ea510c40 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -541,7 +541,7 @@ static int iproc_adc_probe(struct platform_device *pdev)
 
 	adc_priv->irqno = platform_get_irq(pdev, 0);
 	if (adc_priv->irqno <= 0)
-		return -ENODEV;
+		return adc_priv->irqno;
 
 	ret = regmap_update_bits(adc_priv->regmap, IPROC_REGCTL2,
 				IPROC_ADC_AUXIN_SCAN_ENA, 0);
diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
index fa71489195c6..ee20ab09abe5 100644
--- a/drivers/iio/adc/fsl-imx25-gcq.c
+++ b/drivers/iio/adc/fsl-imx25-gcq.c
@@ -340,9 +340,7 @@ static int mx25_gcq_probe(struct platform_device *pdev)
 
 	priv->irq = platform_get_irq(pdev, 0);
 	if (priv->irq <= 0) {
-		ret = priv->irq;
-		if (!ret)
-			ret = -ENXIO;
+		ret = priv->irq ? : -ENXIO;
 		goto err_clk_unprepare;
 	}
 
diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c
index b896f7ff4572..edbb58212fba 100644
--- a/drivers/iio/adc/lpc32xx_adc.c
+++ b/drivers/iio/adc/lpc32xx_adc.c
@@ -173,7 +173,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0)
-		return -ENXIO;
+		return irq ? : -ENXIO;
 
 	retval = devm_request_irq(&pdev->dev, irq, lpc32xx_adc_isr, 0,
 				  LPC32XXAD_NAME, st);
diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
index 910f3585fa54..1e54a64a4534 100644
--- a/drivers/iio/adc/npcm_adc.c
+++ b/drivers/iio/adc/npcm_adc.c
@@ -225,7 +225,7 @@ static int npcm_adc_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
-		ret = -EINVAL;
+		ret = irq ? : -EINVAL;
 		goto err_disable_clk;
 	}
 
diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
index 592b97c464da..9b16717ac7e7 100644
--- a/drivers/iio/adc/spear_adc.c
+++ b/drivers/iio/adc/spear_adc.c
@@ -301,7 +301,7 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
-		ret = -EINVAL;
+		ret = irq ? : -EINVAL;
 		goto errout2;
 	}
 
-- 
Sent by a computer through tubes

  reply	other threads:[~2019-07-31 14:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190730181557.90391-1-swboyd@chromium.org>
2019-07-30 18:15 ` [PATCH v6 19/57] iio: Remove dev_err() usage after platform_get_irq() Stephen Boyd
2019-07-31  6:42   ` Phil Reid
2019-07-31 14:32     ` Stephen Boyd [this message]
2019-08-01  2:37       ` Phil Reid
2019-08-05 15:01         ` Jonathan Cameron
2019-08-05 15:00   ` Jonathan Cameron

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=5d41a66d.1c69fb81.6d372.4c72@mx.google.com \
    --to=swboyd@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=preid@electromag.com.au \
    /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).