2014-11-14 22:21:58

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH] PCI: rcar: fix error handling of irq_of_parse_and_map

Return value of irq_of_parse_and_map() is unsigned int, with 0
indicating failure, so testing for negative result never works.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

Not tested, found by casual code inspection.

drivers/pci/host/pcie-rcar.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 9b356c3..6ca976f 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -764,7 +764,7 @@ static int rcar_pcie_get_resources(struct platform_device *pdev,
goto err_map_reg;

i = irq_of_parse_and_map(pdev->dev.of_node, 0);
- if (i < 0) {
+ if (!i) {
dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
err = -ENOENT;
goto err_map_reg;
@@ -772,7 +772,7 @@ static int rcar_pcie_get_resources(struct platform_device *pdev,
pcie->msi.irq1 = i;

i = irq_of_parse_and_map(pdev->dev.of_node, 1);
- if (i < 0) {
+ if (!i) {
dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
err = -ENOENT;
goto err_map_reg;
--
2.1.0.rc2.206.gedb03e5


--
Dmitry


2014-11-18 10:43:42

by Phil Edworthy

[permalink] [raw]
Subject: RE: [PATCH] PCI: rcar: fix error handling of irq_of_parse_and_map

Hi Dmitry,

On 14 November 2014 22:22, Dmitry wrote:
>
> Return value of irq_of_parse_and_map() is unsigned int, with 0
> indicating failure, so testing for negative result never works.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Acked-by: Phil Edworthy <[email protected]>

Thanks
Phil

> ---
>
> Not tested, found by casual code inspection.
>
> drivers/pci/host/pcie-rcar.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index 9b356c3..6ca976f 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -764,7 +764,7 @@ static int rcar_pcie_get_resources(struct platform_device
> *pdev,
> goto err_map_reg;
>
> i = irq_of_parse_and_map(pdev->dev.of_node, 0);
> - if (i < 0) {
> + if (!i) {
> dev_err(pcie->dev, "cannot get platform resources for msi
> interrupt\n");
> err = -ENOENT;
> goto err_map_reg;
> @@ -772,7 +772,7 @@ static int rcar_pcie_get_resources(struct platform_device
> *pdev,
> pcie->msi.irq1 = i;
>
> i = irq_of_parse_and_map(pdev->dev.of_node, 1);
> - if (i < 0) {
> + if (!i) {
> dev_err(pcie->dev, "cannot get platform resources for msi
> interrupt\n");
> err = -ENOENT;
> goto err_map_reg;
> --
> 2.1.0.rc2.206.gedb03e5
>
>
> --
> Dmitry

2014-12-09 22:38:58

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH] PCI: rcar: fix error handling of irq_of_parse_and_map

On Fri, Nov 14, 2014 at 02:21:53PM -0800, Dmitry Torokhov wrote:
> Return value of irq_of_parse_and_map() is unsigned int, with 0
> indicating failure, so testing for negative result never works.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Applied with Phil's ack to next-pci/host-rcar for v3.19. This branch will
be rebased to v3.19-rc1.

> ---
>
> Not tested, found by casual code inspection.
>
> drivers/pci/host/pcie-rcar.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index 9b356c3..6ca976f 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -764,7 +764,7 @@ static int rcar_pcie_get_resources(struct platform_device *pdev,
> goto err_map_reg;
>
> i = irq_of_parse_and_map(pdev->dev.of_node, 0);
> - if (i < 0) {
> + if (!i) {
> dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
> err = -ENOENT;
> goto err_map_reg;
> @@ -772,7 +772,7 @@ static int rcar_pcie_get_resources(struct platform_device *pdev,
> pcie->msi.irq1 = i;
>
> i = irq_of_parse_and_map(pdev->dev.of_node, 1);
> - if (i < 0) {
> + if (!i) {
> dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
> err = -ENOENT;
> goto err_map_reg;
> --
> 2.1.0.rc2.206.gedb03e5
>
>
> --
> Dmitry