Skip to contentSkip to conversation

net: fsl: Don't use NO_IRQ to check return value of irq_of_parse_and_map()

PATCH Applied Mark Brown 3 participants 6 messages Nov 26, 2015 – Nov 30, 2015

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 net: fsl: Don't use NO_IRQ to check return value of irq_of_parse_and_map()

This driver can be built on arm64 but relies on NO_IRQ to check the return value of irq_of_parse_and_map() which fails to build on arm64 because the architecture does not provide a NO_IRQ. Fix this to correctly check the return value of irq_of_parse_and_map().

Even on ARM systems where the driver was previously used the check was broken since on ARM NO_IRQ is -1 but irq_of_parse_and_map() returns 0 on error.

---
 drivers/net/ethernet/freescale/gianfar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +3 -3
index 67b1850c034e..4ce60e0c8341 100644
@@ -647,9 +647,9 @@ static int gfar_parse_group(struct device_node *np,
 	if (model && strcasecmp(model, "FEC")) {
 		gfar_irq(grp, RX)->irq = irq_of_parse_and_map(np, 1);
 		gfar_irq(grp, ER)->irq = irq_of_parse_and_map(np, 2);
-		if (gfar_irq(grp, TX)->irq == NO_IRQ ||
-		    gfar_irq(grp, RX)->irq == NO_IRQ ||
-		    gfar_irq(grp, ER)->irq == NO_IRQ)
+		if (!gfar_irq(grp, TX)->irq ||
+		    !gfar_irq(grp, RX)->irq ||
+		    !gfar_irq(grp, ER)->irq)
 			return -EINVAL;
 	}
 
Signature · 1 line
2.6.2
author
#1 lore raw

PATCH 2/2 net: fsl: Fix error checking for platform_get_irq()

The gianfar driver has recently been enabled on arm64 but fails to build since it check the return value of platform_get_irq() against NO_IRQ. Fix this by instead checking for a negative error code.

Even on ARM where this code was previously being built this check was incorrect since platform_get_irq() returns a negative error code which may not be exactly the (unsigned int)(-1) that NO_IRQ is defined to be.

---
 drivers/net/ethernet/freescale/gianfar_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/gianfar_ptp.c +1 -1
index 664d0c261269..b40fba929d65 100644
@@ -467,7 +467,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
 
 	etsects->irq = platform_get_irq(dev, 0);
 
-	if (etsects->irq == NO_IRQ) {
+	if (etsects->irq < 0) {
 		pr_err("irq not in device tree\n");
 		goto no_node;
 	}
Signature · 1 line
2.6.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] net: fsl: Fix error checking for platform_get_irq()

From: Mark Brown <[email protected]>
Date: Thu, 26 Nov 2015 11:59:46 +0000

Quoted 9 lines

The gianfar driver has recently been enabled on arm64 but fails to build since it check the return value of platform_get_irq() against NO_IRQ. Fix this by instead checking for a negative error code.

Even on ARM where this code was previously being built this check was incorrect since platform_get_irq() returns a negative error code which may not be exactly the (unsigned int)(-1) that NO_IRQ is defined to be.

Applied.

#3 lore raw

PATCH v2 1/1 gianfar: Don't use NO_IRQ to check return value of irq_of_parse_and_map()

In reply to Mark Brown

From: Mark Brown <[email protected]>

This driver can be built on arm64 but relies on NO_IRQ to check the return value of irq_of_parse_and_map() which fails to build on arm64 because the architecture does not provide a NO_IRQ. Fix this to correctly check the return value of irq_of_parse_and_map().

Even on ARM systems where the driver was previously used the check was broken since on ARM NO_IRQ is -1 but irq_of_parse_and_map() returns 0 on error.

---
v2: even better, do the obvious tx handling fix

 drivers/net/ethernet/freescale/gianfar.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +3 -3
index 3e6b9b4..5fdd2e7 100644
@@ -642,14 +642,14 @@ static int gfar_parse_group(struct device_node *np,
 		return -ENOMEM;
 
 	gfar_irq(grp, TX)->irq = irq_of_parse_and_map(np, 0);
+	if (!gfar_irq(grp, TX)->irq)
+		return -EINVAL;
 
 	/* If we aren't the FEC we have multiple interrupts */
 	if (model && strcasecmp(model, "FEC")) {
 		gfar_irq(grp, RX)->irq = irq_of_parse_and_map(np, 1);
 		gfar_irq(grp, ER)->irq = irq_of_parse_and_map(np, 2);
-		if (gfar_irq(grp, TX)->irq == NO_IRQ ||
-		    gfar_irq(grp, RX)->irq == NO_IRQ ||
-		    gfar_irq(grp, ER)->irq == NO_IRQ)
+		if (!gfar_irq(grp, RX)->irq || !gfar_irq(grp, ER)->irq)
 			return -EINVAL;
 	}
 
Signature · 1 line
1.7.11.7
#4 lore raw
In reply to Mark Brown
Quoted 15 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Thursday, November 26, 2015 2:00 PM
To: Manoil Claudiu-B08782 <[email protected]>; Xie Shaohui- B21989 <[email protected]>; David S . Miller <[email protected]>
Cc: [email protected]; Mark Brown <[email protected]>
Subject: [PATCH 1/2] net: fsl: Don't use NO_IRQ to check return value of irq_of_parse_and_map()

This driver can be built on arm64 but relies on NO_IRQ to check the return value of irq_of_parse_and_map() which fails to build on arm64 because the architecture does not provide a NO_IRQ. Fix this to correctly check the return value of irq_of_parse_and_map().

Quoted 5 lines

Even on ARM systems where the driver was previously used the check was broken since on ARM NO_IRQ is -1 but irq_of_parse_and_map() returns 0 on error.

Ack.
Suggesting the v2 patch below instead, adding a missing fix:
http://patchwork.ozlabs.org/patch/549126/
("[net,v2] gianfar: Don't use NO_IRQ to check return value of irq_of_parse_and_map()")

Thanks,
Claudiu

maintainer Applied
#5 lore raw
In reply to Mark Brown

From: Mark Brown <[email protected]>
Date: Thu, 26 Nov 2015 11:59:45 +0000

Quoted 10 lines

This driver can be built on arm64 but relies on NO_IRQ to check the return value of irq_of_parse_and_map() which fails to build on arm64 because the architecture does not provide a NO_IRQ. Fix this to correctly check the return value of irq_of_parse_and_map().

Even on ARM systems where the driver was previously used the check was broken since on ARM NO_IRQ is -1 but irq_of_parse_and_map() returns 0 on error.

Applied.