Devicetree
 help / color / mirror / Atom feed
* [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
@ 2015-09-08 18:28 David Daney
  2015-09-09 17:37 ` Frank Rowand
  2015-09-09 17:44 ` Frank Rowand
  0 siblings, 2 replies; 4+ messages in thread
From: David Daney @ 2015-09-08 18:28 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Frank Rowand,
	Grant Likely
  Cc: David Daney

From: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>

It is perfectly legitimate for a PCI device to have an
PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't
use interrupts, or on PCIe devices, where only MSI/MSI-X are
supported.

Silence the annoying "of_irq_parse_pci() failed with rc=-19" error
messages by moving the printing code into of_irq_parse_pci(), and only
emitting the message for cases where PCI_INTERRUPT_PIN == 0 is not the
cause for an early exit.

Signed-off-by: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
---
Changes in v2: Move the print function in to of_irq_parse_pci() at a
common error exit point (as suggested by Frank Rowand).


 drivers/of/of_pci_irq.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
index 1710d9d..0be8b65 100644
--- a/drivers/of/of_pci_irq.c
+++ b/drivers/of/of_pci_irq.c
@@ -38,8 +38,8 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
 	 */
 	rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
 	if (rc != 0)
-		return rc;
-	/* No pin, exit */
+		goto err;
+	/* No pin, exit with no error message. */
 	if (pin == 0)
 		return -ENODEV;
 
@@ -53,8 +53,10 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
 			ppnode = pci_bus_to_OF_node(pdev->bus);
 
 			/* No node for host bridge ? give up */
-			if (ppnode == NULL)
-				return -EINVAL;
+			if (ppnode == NULL) {
+				rc = -EINVAL;
+				goto err;
+			}
 		} else {
 			/* We found a P2P bridge, check if it has a node */
 			ppnode = pci_device_to_OF_node(ppdev);
@@ -87,6 +89,9 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
 	laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
 	laddr[1] = laddr[2] = cpu_to_be32(0);
 	return of_irq_parse_raw(laddr, out_irq);
+err:
+	dev_err(&pdev->dev, "of_irq_parse_pci() failed with rc=%d\n", rc);
+	return rc;
 }
 EXPORT_SYMBOL_GPL(of_irq_parse_pci);
 
@@ -105,10 +110,8 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
 	int ret;
 
 	ret = of_irq_parse_pci(dev, &oirq);
-	if (ret) {
-		dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
+	if (ret)
 		return 0; /* Proper return code 0 == NO_IRQ */
-	}
 
 	return irq_create_of_mapping(&oirq);
 }
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
  2015-09-08 18:28 [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages David Daney
@ 2015-09-09 17:37 ` Frank Rowand
  2015-09-09 17:44 ` Frank Rowand
  1 sibling, 0 replies; 4+ messages in thread
From: Frank Rowand @ 2015-09-09 17:37 UTC (permalink / raw)
  To: David Daney; +Cc: devicetree, linux-kernel, Rob Herring, Grant Likely

On 9/8/2015 11:28 AM, David Daney wrote:

> From: David Daney <david.daney@cavium.com>

> 

> It is perfectly legitimate for a PCI device to have an

> PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't

> use interrupts, or on PCIe devices, where only MSI/MSI-X are

> supported.

> 

> Silence the annoying "of_irq_parse_pci() failed with rc=-19" error

> messages by moving the printing code into of_irq_parse_pci(), and only

> emitting the message for cases where PCI_INTERRUPT_PIN == 0 is not the

> cause for an early exit.

> 

> Signed-off-by: David Daney <david.daney@cavium.com>

> ---

> Changes in v2: Move the print function in to of_irq_parse_pci() at a

> common error exit point (as suggested by Frank Rowand).

> 

> 

>  drivers/of/of_pci_irq.c | 17 ++++++++++-------

>  1 file changed, 10 insertions(+), 7 deletions(-)

> 

> diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c

> index 1710d9d..0be8b65 100644

> --- a/drivers/of/of_pci_irq.c

> +++ b/drivers/of/of_pci_irq.c

> @@ -38,8 +38,8 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq

>  	 */

>  	rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);

>  	if (rc != 0)

> -		return rc;

> -	/* No pin, exit */

> +		goto err;

> +	/* No pin, exit with no error message. */

>  	if (pin == 0)

>  		return -ENODEV;

>  

> @@ -53,8 +53,10 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq

>  			ppnode = pci_bus_to_OF_node(pdev->bus);

>  

>  			/* No node for host bridge ? give up */

> -			if (ppnode == NULL)

> -				return -EINVAL;

> +			if (ppnode == NULL) {

> +				rc = -EINVAL;

> +				goto err;

> +			}

>  		} else {

>  			/* We found a P2P bridge, check if it has a node */

>  			ppnode = pci_device_to_OF_node(ppdev);

> @@ -87,6 +89,9 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq

>  	laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));

>  	laddr[1] = laddr[2] = cpu_to_be32(0);


>  	return of_irq_parse_raw(laddr, out_irq);


should be:

        rc = of_irq_parse_raw(laddr, out_irq);
        if (rc)
                goto err;
        return 0;

> +err:

> +	dev_err(&pdev->dev, "of_irq_parse_pci() failed with rc=%d\n", rc);

> +	return rc;

>  }

>  EXPORT_SYMBOL_GPL(of_irq_parse_pci);

>  

> @@ -105,10 +110,8 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)

>  	int ret;

>  

>  	ret = of_irq_parse_pci(dev, &oirq);

> -	if (ret) {

> -		dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);

> +	if (ret)

>  		return 0; /* Proper return code 0 == NO_IRQ */

> -	}

>  

>  	return irq_create_of_mapping(&oirq);

>  }

> 

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

* Re: [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
  2015-09-08 18:28 [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages David Daney
  2015-09-09 17:37 ` Frank Rowand
@ 2015-09-09 17:44 ` Frank Rowand
  2015-09-09 17:53   ` David Daney
  1 sibling, 1 reply; 4+ messages in thread
From: Frank Rowand @ 2015-09-09 17:44 UTC (permalink / raw)
  To: David Daney
  Cc: devicetree, linux-kernel, Rob Herring, Grant Likely, David Daney

Second attempt at this reply.  The first reply was mangled.

On 9/8/2015 11:28 AM, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
> 
> It is perfectly legitimate for a PCI device to have an
> PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't
> use interrupts, or on PCIe devices, where only MSI/MSI-X are
> supported.
> 
> Silence the annoying "of_irq_parse_pci() failed with rc=-19" error
> messages by moving the printing code into of_irq_parse_pci(), and only
> emitting the message for cases where PCI_INTERRUPT_PIN == 0 is not the
> cause for an early exit.
> 
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
> Changes in v2: Move the print function in to of_irq_parse_pci() at a
> common error exit point (as suggested by Frank Rowand).
> 
> 
>  drivers/of/of_pci_irq.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
> index 1710d9d..0be8b65 100644
> --- a/drivers/of/of_pci_irq.c
> +++ b/drivers/of/of_pci_irq.c
> @@ -38,8 +38,8 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
>  	 */
>  	rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
>  	if (rc != 0)
> -		return rc;
> -	/* No pin, exit */
> +		goto err;
> +	/* No pin, exit with no error message. */
>  	if (pin == 0)
>  		return -ENODEV;
>  
> @@ -53,8 +53,10 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
>  			ppnode = pci_bus_to_OF_node(pdev->bus);
>  
>  			/* No node for host bridge ? give up */
> -			if (ppnode == NULL)
> -				return -EINVAL;
> +			if (ppnode == NULL) {
> +				rc = -EINVAL;
> +				goto err;
> +			}
>  		} else {
>  			/* We found a P2P bridge, check if it has a node */
>  			ppnode = pci_device_to_OF_node(ppdev);
> @@ -87,6 +89,9 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
>  	laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
>  	laddr[1] = laddr[2] = cpu_to_be32(0);

>  	return of_irq_parse_raw(laddr, out_irq);

should be:

        rc = of_irq_parse_raw(laddr, out_irq);
        if (rc)
                goto err;
        return 0;

> +err:
> +	dev_err(&pdev->dev, "of_irq_parse_pci() failed with rc=%d\n", rc);
> +	return rc;
>  }
>  EXPORT_SYMBOL_GPL(of_irq_parse_pci);
>  
> @@ -105,10 +110,8 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
>  	int ret;
>  
>  	ret = of_irq_parse_pci(dev, &oirq);
> -	if (ret) {
> -		dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
> +	if (ret)
>  		return 0; /* Proper return code 0 == NO_IRQ */
> -	}
>  
>  	return irq_create_of_mapping(&oirq);
>  }
> 

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

* Re: [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
  2015-09-09 17:44 ` Frank Rowand
@ 2015-09-09 17:53   ` David Daney
  0 siblings, 0 replies; 4+ messages in thread
From: David Daney @ 2015-09-09 17:53 UTC (permalink / raw)
  To: frowand.list
  Cc: David Daney, devicetree, linux-kernel, Rob Herring, Grant Likely,
	David Daney

On 09/09/2015 10:44 AM, Frank Rowand wrote:
> Second attempt at this reply.  The first reply was mangled.
>
> On 9/8/2015 11:28 AM, David Daney wrote:
>> From: David Daney <david.daney@cavium.com>
>>
>> It is perfectly legitimate for a PCI device to have an
>> PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't
>> use interrupts, or on PCIe devices, where only MSI/MSI-X are
>> supported.
>>
>> Silence the annoying "of_irq_parse_pci() failed with rc=-19" error
>> messages by moving the printing code into of_irq_parse_pci(), and only
>> emitting the message for cases where PCI_INTERRUPT_PIN == 0 is not the
>> cause for an early exit.
>>
>> Signed-off-by: David Daney <david.daney@cavium.com>
>> ---
>> Changes in v2: Move the print function in to of_irq_parse_pci() at a
>> common error exit point (as suggested by Frank Rowand).
>>
>>
[...]
>> @@ -87,6 +89,9 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
>>   	laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
>>   	laddr[1] = laddr[2] = cpu_to_be32(0);
>
>>   	return of_irq_parse_raw(laddr, out_irq);
>
> should be:
>
>          rc = of_irq_parse_raw(laddr, out_irq);
>          if (rc)
>                  goto err;
>          return 0;
>

You are right.  I will send v3.

Thanks,
David Daney

>> +err:
>> +	dev_err(&pdev->dev, "of_irq_parse_pci() failed with rc=%d\n", rc);
>> +	return rc;

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

end of thread, other threads:[~2015-09-09 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 18:28 [PATCH v2] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages David Daney
2015-09-09 17:37 ` Frank Rowand
2015-09-09 17:44 ` Frank Rowand
2015-09-09 17:53   ` David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox