All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error
@ 2017-10-14 22:07 Fabio Estevam
  2017-10-14 22:07 ` [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling Fabio Estevam
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Fabio Estevam @ 2017-10-14 22:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Thomas Petazzoni

platform_get_irq() may fail and in the case of failure the error value
should be propagated.

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/pci/host/pci-aardvark.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
index 26ed0c0..f3b16ff 100644
--- a/drivers/pci/host/pci-aardvark.c
+++ b/drivers/pci/host/pci-aardvark.c
@@ -901,6 +901,8 @@ static int advk_pcie_probe(struct platform_device *pdev)
 		return PTR_ERR(pcie->base);
 
 	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 	ret = devm_request_irq(dev, irq, advk_pcie_irq_handler,
 			       IRQF_SHARED | IRQF_NO_THREAD, "advk-pcie",
 			       pcie);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling
  2017-10-14 22:07 [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error Fabio Estevam
@ 2017-10-14 22:07 ` Fabio Estevam
  2017-10-14 22:26   ` Linus Walleij
  2017-10-14 22:07 ` [PATCH 3/5] PCI: mediatek: Check for platform_get_irq() error Fabio Estevam
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2017-10-14 22:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Linus Walleij

When platform_get_irq() fails we should propagate the real error value
instead of always returning -ENODEV.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/pci/host/pci-v3-semi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pci-v3-semi.c b/drivers/pci/host/pci-v3-semi.c
index a544d72..01017af 100644
--- a/drivers/pci/host/pci-v3-semi.c
+++ b/drivers/pci/host/pci-v3-semi.c
@@ -806,9 +806,9 @@ static int v3_pci_probe(struct platform_device *pdev)
 
 	/* Get and request error IRQ resource */
 	irq = platform_get_irq(pdev, 0);
-	if (irq <= 0) {
+	if (irq < 0) {
 		dev_err(dev, "unable to obtain PCIv3 error IRQ\n");
-		return -ENODEV;
+		return irq;
 	}
 	ret = devm_request_irq(dev, irq, v3_irq, 0,
 			"PCIv3 error", v3);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] PCI: mediatek: Check for platform_get_irq() error
  2017-10-14 22:07 [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error Fabio Estevam
  2017-10-14 22:07 ` [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling Fabio Estevam
@ 2017-10-14 22:07 ` Fabio Estevam
  2017-10-14 22:07 ` [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling Fabio Estevam
  2017-10-14 22:07 ` [PATCH 5/5] PCI: xilinx-nwl: " Fabio Estevam
  3 siblings, 0 replies; 11+ messages in thread
From: Fabio Estevam @ 2017-10-14 22:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Ryder Lee

platform_get_irq() may fail and in the case of failure the error value
should be propagated.

Cc: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/pci/host/pcie-mediatek.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c
index db93efd..05f8c33 100644
--- a/drivers/pci/host/pcie-mediatek.c
+++ b/drivers/pci/host/pcie-mediatek.c
@@ -642,6 +642,8 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
 	int err, irq;
 
 	irq = platform_get_irq(pdev, port->slot);
+	if (irq < 0)
+		return irq;
 	err = devm_request_irq(dev, irq, mtk_pcie_intr_handler,
 			       IRQF_SHARED, "mtk-pcie", port);
 	if (err) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling
  2017-10-14 22:07 [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error Fabio Estevam
  2017-10-14 22:07 ` [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling Fabio Estevam
  2017-10-14 22:07 ` [PATCH 3/5] PCI: mediatek: Check for platform_get_irq() error Fabio Estevam
@ 2017-10-14 22:07 ` Fabio Estevam
  2017-10-16  9:09   ` Marc Gonzalez
  2017-10-14 22:07 ` [PATCH 5/5] PCI: xilinx-nwl: " Fabio Estevam
  3 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2017-10-14 22:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Marc Gonzalez

When platform_get_irq() fails we should propagate the real error value
instead of always returning -ENXIO.

Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/pci/host/pcie-tango.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pcie-tango.c b/drivers/pci/host/pcie-tango.c
index e23f738..5196583 100644
--- a/drivers/pci/host/pcie-tango.c
+++ b/drivers/pci/host/pcie-tango.c
@@ -272,9 +272,9 @@ static int tango_pcie_probe(struct platform_device *pdev)
 		writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset);
 
 	virq = platform_get_irq(pdev, 1);
-	if (virq <= 0) {
+	if (virq < 0) {
 		dev_err(dev, "Failed to map IRQ\n");
-		return -ENXIO;
+		return virq;
 	}
 
 	irq_dom = irq_domain_create_linear(fwnode, MSI_MAX, &dom_ops, pcie);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] PCI: xilinx-nwl: Fix platform_get_irq() error handling
  2017-10-14 22:07 [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error Fabio Estevam
                   ` (2 preceding siblings ...)
  2017-10-14 22:07 ` [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling Fabio Estevam
@ 2017-10-14 22:07 ` Fabio Estevam
  2017-10-17  8:55   ` Michal Simek
  3 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2017-10-14 22:07 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, Fabio Estevam, Michal Simek

When platform_get_irq() fails we should propagate the real error value
instead of always returning -EINVAL.

Cc: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/pci/host/pcie-xilinx-nwl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
index 65dea98..b896167 100644
--- a/drivers/pci/host/pcie-xilinx-nwl.c
+++ b/drivers/pci/host/pcie-xilinx-nwl.c
@@ -591,7 +591,7 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
 	msi->irq_msi1 = platform_get_irq_byname(pdev, "msi1");
 	if (msi->irq_msi1 < 0) {
 		dev_err(dev, "failed to get IRQ#%d\n", msi->irq_msi1);
-		ret = -EINVAL;
+		ret = msi->irq_msi1;
 		goto err;
 	}
 
@@ -602,7 +602,7 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
 	msi->irq_msi0 = platform_get_irq_byname(pdev, "msi0");
 	if (msi->irq_msi0 < 0) {
 		dev_err(dev, "failed to get IRQ#%d\n", msi->irq_msi0);
-		ret = -EINVAL;
+		ret = msi->irq_msi0;
 		goto err;
 	}
 
@@ -735,7 +735,7 @@ static int nwl_pcie_bridge_init(struct nwl_pcie *pcie)
 	if (pcie->irq_misc < 0) {
 		dev_err(dev, "failed to get misc IRQ %d\n",
 			pcie->irq_misc);
-		return -EINVAL;
+		return pcie->irq_misc;
 	}
 
 	err = devm_request_irq(dev, pcie->irq_misc,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling
  2017-10-14 22:07 ` [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling Fabio Estevam
@ 2017-10-14 22:26   ` Linus Walleij
  0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2017-10-14 22:26 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: bhelgaas, linux-pci

On Sun, Oct 15, 2017 at 12:07 AM, Fabio Estevam <festevam@gmail.com> wrote:

> When platform_get_irq() fails we should propagate the real error value
> instead of always returning -ENODEV.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

OK

>         irq = platform_get_irq(pdev, 0);
> -       if (irq <= 0) {
> +       if (irq < 0) {

So 0 is NO_IRQ and not valid these days. See:
https://lwn.net/Articles/470820/

>                 dev_err(dev, "unable to obtain PCIv3 error IRQ\n");
> -               return -ENODEV;
> +               return irq;

But this is right, if irq < 0.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling
  2017-10-14 22:07 ` [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling Fabio Estevam
@ 2017-10-16  9:09   ` Marc Gonzalez
  2017-10-16  9:19     ` Linus Walleij
  2017-10-20 22:31     ` Bjorn Helgaas
  0 siblings, 2 replies; 11+ messages in thread
From: Marc Gonzalez @ 2017-10-16  9:09 UTC (permalink / raw)
  To: Fabio Estevam, Bjorn Helgaas
  Cc: linux-pci, Greg Kroah-Hartman, Marc Zyngier, Thomas Gleixner,
	Linus Walleij, Mason

+ gkh, maz, tglx, linus w

On 15/10/2017 00:07, Fabio Estevam wrote:

> When platform_get_irq() fails we should propagate the real error value
> instead of always returning -ENXIO.
> 
> Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> ---
>  drivers/pci/host/pcie-tango.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-tango.c b/drivers/pci/host/pcie-tango.c
> index e23f738..5196583 100644
> --- a/drivers/pci/host/pcie-tango.c
> +++ b/drivers/pci/host/pcie-tango.c
> @@ -272,9 +272,9 @@ static int tango_pcie_probe(struct platform_device *pdev)
>  		writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset);
>  
>  	virq = platform_get_irq(pdev, 1);
> -	if (virq <= 0) {
> +	if (virq < 0) {
>  		dev_err(dev, "Failed to map IRQ\n");
> -		return -ENXIO;
> +		return virq;
>  	}
>  
>  	irq_dom = irq_domain_create_linear(fwnode, MSI_MAX, &dom_ops, pcie);

Hello Fabio,

I don't think this patch is correct.

AFAIU, on all but legacy platforms, when platform_get_irq() returns 0,
it is to signal an error condition.

Marc Z pointed out this discussion:
http://yarchive.net/comp/linux/zero.html

Looking more closely at the platform_get_irq implementation, and ignoring
the CONFIG_SPARC special-case, the return value is either:

* a valid virq > 0, or
* -EPROBE_DEFER, or
* some error code < 0, in the ACPI case, or
* -ENXIO, or
* res->start (an unsigned type, so >= 0)


I suppose it would be slightly nicer to write:

	virq = platform_get_irq(pdev, 1);
	if (virq <= 0)
		return virq ? virq : -ENODEV;

Regards.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling
  2017-10-16  9:09   ` Marc Gonzalez
@ 2017-10-16  9:19     ` Linus Walleij
  2017-10-20 22:31     ` Bjorn Helgaas
  1 sibling, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2017-10-16  9:19 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Fabio Estevam, Bjorn Helgaas, linux-pci, Greg Kroah-Hartman,
	Marc Zyngier, Thomas Gleixner, Mason

On Mon, Oct 16, 2017 at 11:09 AM, Marc Gonzalez
<marc_gonzalez@sigmadesigns.com> wrote:

> I don't think this patch is correct.
>
> AFAIU, on all but legacy platforms, when platform_get_irq() returns 0,
> it is to signal an error condition.
>
> Marc Z pointed out this discussion:
> http://yarchive.net/comp/linux/zero.html

Same comment as I had, more or less.

> I suppose it would be slightly nicer to write:
>
>         virq = platform_get_irq(pdev, 1);
>         if (virq <= 0)
>                 return virq ? virq : -ENODEV;

This looks good to me.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] PCI: xilinx-nwl: Fix platform_get_irq() error handling
  2017-10-14 22:07 ` [PATCH 5/5] PCI: xilinx-nwl: " Fabio Estevam
@ 2017-10-17  8:55   ` Michal Simek
  0 siblings, 0 replies; 11+ messages in thread
From: Michal Simek @ 2017-10-17  8:55 UTC (permalink / raw)
  To: Fabio Estevam, bhelgaas; +Cc: linux-pci, Michal Simek

On 15.10.2017 00:07, Fabio Estevam wrote:
> When platform_get_irq() fails we should propagate the real error value
> instead of always returning -EINVAL.
> 
> Cc: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> ---
>  drivers/pci/host/pcie-xilinx-nwl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
> index 65dea98..b896167 100644
> --- a/drivers/pci/host/pcie-xilinx-nwl.c
> +++ b/drivers/pci/host/pcie-xilinx-nwl.c
> @@ -591,7 +591,7 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
>  	msi->irq_msi1 = platform_get_irq_byname(pdev, "msi1");
>  	if (msi->irq_msi1 < 0) {
>  		dev_err(dev, "failed to get IRQ#%d\n", msi->irq_msi1);
> -		ret = -EINVAL;
> +		ret = msi->irq_msi1;
>  		goto err;
>  	}
>  
> @@ -602,7 +602,7 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
>  	msi->irq_msi0 = platform_get_irq_byname(pdev, "msi0");
>  	if (msi->irq_msi0 < 0) {
>  		dev_err(dev, "failed to get IRQ#%d\n", msi->irq_msi0);
> -		ret = -EINVAL;
> +		ret = msi->irq_msi0;
>  		goto err;
>  	}
>  
> @@ -735,7 +735,7 @@ static int nwl_pcie_bridge_init(struct nwl_pcie *pcie)
>  	if (pcie->irq_misc < 0) {
>  		dev_err(dev, "failed to get misc IRQ %d\n",
>  			pcie->irq_misc);
> -		return -EINVAL;
> +		return pcie->irq_misc;
>  	}
>  
>  	err = devm_request_irq(dev, pcie->irq_misc,
> 

Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling
  2017-10-16  9:09   ` Marc Gonzalez
  2017-10-16  9:19     ` Linus Walleij
@ 2017-10-20 22:31     ` Bjorn Helgaas
  2017-10-26  6:37       ` Mason
  1 sibling, 1 reply; 11+ messages in thread
From: Bjorn Helgaas @ 2017-10-20 22:31 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Fabio Estevam, Bjorn Helgaas, linux-pci, Greg Kroah-Hartman,
	Marc Zyngier, Thomas Gleixner, Linus Walleij, Mason

On Mon, Oct 16, 2017 at 11:09:15AM +0200, Marc Gonzalez wrote:
> + gkh, maz, tglx, linus w
> 
> On 15/10/2017 00:07, Fabio Estevam wrote:
> 
> > When platform_get_irq() fails we should propagate the real error value
> > instead of always returning -ENXIO.
> > 
> > Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > ---
> >  drivers/pci/host/pcie-tango.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pci/host/pcie-tango.c b/drivers/pci/host/pcie-tango.c
> > index e23f738..5196583 100644
> > --- a/drivers/pci/host/pcie-tango.c
> > +++ b/drivers/pci/host/pcie-tango.c
> > @@ -272,9 +272,9 @@ static int tango_pcie_probe(struct platform_device *pdev)
> >  		writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset);
> >  
> >  	virq = platform_get_irq(pdev, 1);
> > -	if (virq <= 0) {
> > +	if (virq < 0) {
> >  		dev_err(dev, "Failed to map IRQ\n");
> > -		return -ENXIO;
> > +		return virq;
> >  	}
> >  
> >  	irq_dom = irq_domain_create_linear(fwnode, MSI_MAX, &dom_ops, pcie);
> 
> Hello Fabio,
> 
> I don't think this patch is correct.
> 
> AFAIU, on all but legacy platforms, when platform_get_irq() returns 0,
> it is to signal an error condition.
> 
> Marc Z pointed out this discussion:
> http://yarchive.net/comp/linux/zero.html
> 
> Looking more closely at the platform_get_irq implementation, and ignoring
> the CONFIG_SPARC special-case, the return value is either:
> 
> * a valid virq > 0, or
> * -EPROBE_DEFER, or
> * some error code < 0, in the ACPI case, or
> * -ENXIO, or
> * res->start (an unsigned type, so >= 0)
> 
> 
> I suppose it would be slightly nicer to write:
> 
> 	virq = platform_get_irq(pdev, 1);
> 	if (virq <= 0)
> 		return virq ? virq : -ENODEV;

All these return values end up getting returned by the driver probe()
functions.  I don't think there's much value in returning the exact
error we got from platform_get_irq() vs a generic error like -ENXIO or
-ENODEV, so my $0.02 is that the above is more complicated than it's
worth.

I think existing code that looks like:

  irq = platform_get_irq(pdev, 0);
  if (irq <= 0)
    return -ENODEV;

is fine and there's no reason to change it.  For code that doesn't
check the platform_get_irq() return value, I'd say it's worth adding a
check for "irq <= 0".  Maybe somebody will point out an arch that can
return 0 as a legitimate IRQ, and then we'll have to rethink.

Bjorn

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling
  2017-10-20 22:31     ` Bjorn Helgaas
@ 2017-10-26  6:37       ` Mason
  0 siblings, 0 replies; 11+ messages in thread
From: Mason @ 2017-10-26  6:37 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Marc Gonzalez, Fabio Estevam, Bjorn Helgaas, linux-pci,
	Greg Kroah-Hartman, Marc Zyngier, Thomas Gleixner, Linus Walleij,
	Linus Torvalds, Mark Brown

+ linus t, mark b

On 21/10/2017 00:31, Bjorn Helgaas wrote:

> On Mon, Oct 16, 2017 at 11:09:15AM +0200, Marc Gonzalez wrote:
>
>> + gkh, maz, tglx, linus w
>>
>> On 15/10/2017 00:07, Fabio Estevam wrote:
>>
>>> When platform_get_irq() fails we should propagate the real error value
>>> instead of always returning -ENXIO.
>>>
>>> Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
>>> Signed-off-by: Fabio Estevam <festevam@gmail.com>
>>> ---
>>>  drivers/pci/host/pcie-tango.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/pci/host/pcie-tango.c b/drivers/pci/host/pcie-tango.c
>>> index e23f738..5196583 100644
>>> --- a/drivers/pci/host/pcie-tango.c
>>> +++ b/drivers/pci/host/pcie-tango.c
>>> @@ -272,9 +272,9 @@ static int tango_pcie_probe(struct platform_device *pdev)
>>>  		writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset);
>>>  
>>>  	virq = platform_get_irq(pdev, 1);
>>> -	if (virq <= 0) {
>>> +	if (virq < 0) {
>>>  		dev_err(dev, "Failed to map IRQ\n");
>>> -		return -ENXIO;
>>> +		return virq;
>>>  	}
>>>  
>>>  	irq_dom = irq_domain_create_linear(fwnode, MSI_MAX, &dom_ops, pcie);
>>
>> Hello Fabio,
>>
>> I don't think this patch is correct.
>>
>> AFAIU, on all but legacy platforms, when platform_get_irq() returns 0,
>> it is to signal an error condition.
>>
>> Marc Z pointed out this discussion:
>> http://yarchive.net/comp/linux/zero.html
>>
>> Looking more closely at the platform_get_irq implementation, and ignoring
>> the CONFIG_SPARC special-case, the return value is either:
>>
>> * a valid virq > 0, or
>> * -EPROBE_DEFER, or
>> * some error code < 0, in the ACPI case, or
>> * -ENXIO, or
>> * res->start (an unsigned type, so >= 0)
>>
>>
>> I suppose it would be slightly nicer to write:
>>
>> 	virq = platform_get_irq(pdev, 1);
>> 	if (virq <= 0)
>> 		return virq ? virq : -ENODEV;
> 
> All these return values end up getting returned by the driver probe()
> functions.  I don't think there's much value in returning the exact
> error we got from platform_get_irq() vs a generic error like -ENXIO or
> -ENODEV, so my $0.02 is that the above is more complicated than it's
> worth.
> 
> I think existing code that looks like:
> 
>   irq = platform_get_irq(pdev, 0);
>   if (irq <= 0)
>     return -ENODEV;
> 
> is fine and there's no reason to change it.  For code that doesn't
> check the platform_get_irq() return value, I'd say it's worth adding a
> check for "irq <= 0".  Maybe somebody will point out an arch that can
> return 0 as a legitimate IRQ, and then we'll have to rethink.

I agree with what Bjorn wrote, but there might be one exception
to consider: mapping EPROBE_DEFER to something else will likely
prevent the driver core from correctly handling deferred probes.

References for myself:
https://lwn.net/Articles/485194/
https://patchwork.kernel.org/patch/9558675/

Regards.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-26  6:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-14 22:07 [PATCH 1/5] PCI: aardvark: Check for platform_get_irq() error Fabio Estevam
2017-10-14 22:07 ` [PATCH 2/5] PCI: v3-semi: Fix platform_get_irq() error handling Fabio Estevam
2017-10-14 22:26   ` Linus Walleij
2017-10-14 22:07 ` [PATCH 3/5] PCI: mediatek: Check for platform_get_irq() error Fabio Estevam
2017-10-14 22:07 ` [PATCH 4/5] PCI: tango: Fix platform_get_irq() error handling Fabio Estevam
2017-10-16  9:09   ` Marc Gonzalez
2017-10-16  9:19     ` Linus Walleij
2017-10-20 22:31     ` Bjorn Helgaas
2017-10-26  6:37       ` Mason
2017-10-14 22:07 ` [PATCH 5/5] PCI: xilinx-nwl: " Fabio Estevam
2017-10-17  8:55   ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.