On Wed, Aug 07, 2019 at 04:09:10PM +0200, Marc Gonzalez wrote:
> On 30/07/2019 23:56, Bjorn Helgaas wrote:
> 
> >> diff --git a/drivers/pci/controller/pcie-tango.c 
> >> b/drivers/pci/controller/pcie-tango.c
> >> index 21a208da3f59..b87aa9041480 100644
> >> --- a/drivers/pci/controller/pcie-tango.c
> >> +++ b/drivers/pci/controller/pcie-tango.c
> >> @@ -273,10 +273,8 @@ 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) {
> >> -          dev_err(dev, "Failed to map IRQ\n");
> >> +  if (virq <= 0)
> >>            return -ENXIO;
> >
> > Why <= 0 and -ENXIO?
> 
> Smirk. I remember discussing this in the past...
> Here it is:
> 
>       https://patchwork.kernel.org/patch/10006651/

Sigh, what a mess.  I did say in that discussion that it wasn't worth
changing existing "irq <= 0" tests.  I can't remember why I said that,
but I think I was wrong.

platform_get_irq() is a generic interface and we have to be able to
interpret return values consistently.  The overwhelming consensus
among platform_get_irq() callers is to treat "irq < 0" as an error,
and I think we should follow suit.

> A) AFAIU platform_get_irq() = 0 signals an error.
> 
>       https://yarchive.net/comp/linux/zero.html
>       https://lkml.org/lkml/2016/2/9/212
>       https://patchwork.ozlabs.org/patch/486056/
> 
> B) I don't remember why I picked ENXIO.
> Perhaps it made more sense to me (at the time) than EINVAL or ENODEV.

I think the best pattern is:

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

There's not an overwhelming consensus on whether to return the result
of platform_get_irq() or a hard-coded -ENXIO/-EINVAL/-ENODEV etc, but
why throw away information?

Bjorn

Reply via email to