From: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: dave.martin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
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-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
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
next prev parent 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
[not found] ` <1316550244-3655-1-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-20 20:24 ` Rob Herring [this message]
[not found] ` <1316550244-3655-2-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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
[not found] ` <1316550244-3655-3-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-21 10:01 ` Jamie Iles
2011-09-23 2:21 ` [PATCH v3] " Rob Herring
[not found] ` <1316744473-13158-1-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-23 5:14 ` Grant Likely
2011-09-26 19:24 ` [PATCH v4] " Rob Herring
[not found] ` <1317065083-23573-1-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-27 1:53 ` Grant Likely
[not found] ` <20110927015305.GD20588-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
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
[not found] ` <1316550244-3655-4-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-20 23:08 ` Grant Likely
[not found] ` <20110920230800.GS7781-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-09-21 1:54 ` Rob Herring
2011-09-21 17:15 ` Cousson, Benoit
[not found] ` <4E7A1BCA.1090006-l0cyMroinI0@public.gmane.org>
2011-09-21 17:55 ` Rob Herring
[not found] ` <4E7A252F.2000402-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-21 19:28 ` Cousson, Benoit
[not found] ` <4E7A3AF0.1020809-l0cyMroinI0@public.gmane.org>
2011-09-21 20:27 ` Cousson, Benoit
2011-09-26 19:57 ` Jamie Iles
2011-09-26 20:49 ` Rob Herring
[not found] ` <4E80E547.2080004-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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 9:43 ` [PATCH 0/3] GIC OF bindings Shawn Guo
2011-09-21 2:49 ` David Miller
2011-09-21 4:14 ` Grant Likely
[not found] ` <CACxGe6t7Mdr+w+aGFPM2-FEAQaYHuG8Za9dybLgMo-5-whLyNQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-21 4:58 ` Mitch Bradley
2011-09-21 5:21 ` David Miller
[not found] ` <20110921.012158.2252182592946972727.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2011-09-21 7:11 ` Mitch Bradley
[not found] ` <20110920.224910.1996429830782124690.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2011-09-21 5:16 ` Segher Boessenkool
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-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dave.martin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.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).