linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child
Date: Tue, 20 Sep 2011 15:24:02 -0500	[thread overview]
Message-ID: <1316550244-3655-2-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1316550244-3655-1-git-send-email-robherring2@gmail.com>

From: Rob Herring <rob.herring@calxeda.com>

An interrupt controller may often implicitly inherit itself from a parent
node when in fact the controller is the interrupt root controller. Guard
against the case of child == parent and return NULL in this case.

This can also be fixed by adding an explicit "interrupt-parent;" to a root
interrupt controller node.

Based on code from Grant Likely.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/of/irq.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 9f689f1..6a5b5e7 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -58,27 +58,27 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
  */
 struct device_node *of_irq_find_parent(struct device_node *child)
 {
-	struct device_node *p;
+	struct device_node *p, *c = child;
 	const __be32 *parp;
 
-	if (!of_node_get(child))
+	if (!of_node_get(c))
 		return NULL;
 
 	do {
-		parp = of_get_property(child, "interrupt-parent", NULL);
+		parp = of_get_property(c, "interrupt-parent", NULL);
 		if (parp == NULL)
-			p = of_get_parent(child);
+			p = of_get_parent(c);
 		else {
 			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
 				p = of_node_get(of_irq_dflt_pic);
 			else
 				p = of_find_node_by_phandle(be32_to_cpup(parp));
 		}
-		of_node_put(child);
-		child = p;
+		of_node_put(c);
+		c = p;
 	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
 
-	return p;
+	return (p == child) ? NULL : p;
 }
 
 /**
-- 
1.7.5.4

  reply	other threads:[~2011-09-20 20:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 20:24 [PATCH 0/3] GIC OF bindings Rob Herring
2011-09-20 20:24 ` Rob Herring [this message]
2011-09-20 21:01   ` [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child Grant Likely
2011-09-20 20:24 ` [PATCH 2/3] of/irq: introduce of_irq_init Rob Herring
2011-09-20 23:00   ` Grant Likely
2011-09-21 10:01   ` Jamie Iles
2011-09-23  2:21   ` [PATCH v3] " Rob Herring
2011-09-23  5:14     ` Grant Likely
2011-09-26 19:24     ` [PATCH v4] " Rob Herring
2011-09-27  1:53       ` Grant Likely
2011-09-27 13:03         ` Rob Herring
2011-09-27 21:24           ` Grant Likely
2011-09-20 20:24 ` [PATCH 3/3] ARM: gic: add OF based initialization Rob Herring
2011-09-20 23:08   ` Grant Likely
2011-09-21  1:54     ` Rob Herring
2011-09-21 17:15   ` Cousson, Benoit
2011-09-21 17:55     ` Rob Herring
2011-09-21 19:28       ` Cousson, Benoit
2011-09-21 20:27         ` Cousson, Benoit
2011-09-26 19:57   ` Jamie Iles
2011-09-26 20:49     ` Rob Herring
2011-09-26 21:11       ` Jamie Iles
2011-09-26 21:32         ` Rob Herring
2011-09-26 22:00           ` Jamie Iles
2011-09-26 22:29   ` Jamie Iles
2011-09-21  2:49 ` [PATCH 0/3] GIC OF bindings David Miller
2011-09-21  4:14   ` Grant Likely
2011-09-21  4:58     ` Mitch Bradley
2011-09-21  5:21       ` David Miller
2011-09-21  7:11         ` Mitch Bradley
2011-09-21  5:16   ` Segher Boessenkool
2011-09-21  9:43 ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316550244-3655-2-git-send-email-robherring2@gmail.com \
    --to=robherring2@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).