[PATCH] of: Fixup interrupt parsing failure.

From: Grant Likely
Date: Fri Nov 01 2013 - 13:50:50 EST


Signed-off-by: Grant Likely <grant.likely@xxxxxxxxxx>
---
drivers/of/irq.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 8cc62b4a7988..c3427c8579a2 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -17,7 +17,7 @@
* device tree to actual irq numbers on an interrupt controller
* driver.
*/
-
+#define DEBUG
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/module.h>
@@ -97,7 +97,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
__be32 initial_match_array[8];
const __be32 *match_array = initial_match_array;
- const __be32 *tmp, *imap, *imask, dummy_imask[] = { ~0, ~0, ~0, ~0, ~0 };
+ const __be32 *tmp, *imap, *imask, dummy_imask[] = { ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 };
u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
int imaplen, match, i;

@@ -147,21 +147,14 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)

pr_debug(" -> addrsize=%d\n", addrsize);

- /* If we were passed no "reg" property and we attempt to parse
- * an interrupt-map, then #address-cells must be 0.
- * Fail if it's not.
- */
- if (addr == NULL && addrsize != 0) {
- pr_debug(" -> no reg passed in when needed !\n");
- return -EINVAL;
+ if (addrsize && addr) {
+ /* Precalculate the initial match array to simplify match loop */
+ for (i = 0; i < addrsize; i++)
+ initial_match_array[i] = addr[i];
+ for (i = 0; i < intsize; i++)
+ initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]);
}

- /* Precalculate the match array - this simplifies match loop */
- for (i = 0; i < addrsize; i++)
- initial_match_array[i] = addr[i];
- for (i = 0; i < intsize; i++)
- initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]);
-
/* Now start the actual "proper" walk of the interrupt tree */
while (ipar != NULL) {
/* Now check if cursor is an interrupt-controller and if it is
@@ -174,6 +167,15 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
return 0;
}

+ /* If we were passed no "reg" property and we attempt to parse
+ * an interrupt-map, then #address-cells must be 0.
+ * Fail if it's not.
+ */
+ if (addrsize && !addr) {
+ pr_debug(" -> no reg passed in when needed !\n");
+ return -EINVAL;
+ }
+
/* Now look for an interrupt-map */
imap = of_get_property(ipar, "interrupt-map", &imaplen);
/* No interrupt map, check for an interrupt parent */
--
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/