linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Michal Simek <monstr@monstr.eu>,
	microblaze-uclinux@itee.uq.edu.au,
	devicetree-discuss@lists.ozlabs.org,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 3/5] of/irq: merge of_irq_find_parent()
Date: Fri, 04 Jun 2010 15:21:45 -0600	[thread overview]
Message-ID: <20100604212145.10552.95452.stgit@angua> (raw)
In-Reply-To: <20100604212134.10552.70717.stgit@angua>

Merge common code between PowerPC and Microblaze.  Also create a new
arch hook, of_irq_find_parent_by_phandle() to handle arch-specific
quirks.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Michal Simek <monstr@monstr.eu>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
CC: microblaze-uclinux@itee.uq.edu.au
CC: linuxppc-dev@lists.ozlabs.org
CC: devicetree-discuss@lists.ozlabs.org
---
 arch/microblaze/kernel/prom_parse.c |   22 +++-------------------
 arch/powerpc/kernel/prom_parse.c    |   30 +++++-------------------------
 drivers/of/irq.c                    |   28 ++++++++++++++++++++++++++++
 include/linux/of_irq.h              |    2 ++
 4 files changed, 38 insertions(+), 44 deletions(-)

diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c
index af1b2a7..946f14d 100644
--- a/arch/microblaze/kernel/prom_parse.c
+++ b/arch/microblaze/kernel/prom_parse.c
@@ -648,25 +648,9 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  * Interrupt remapper
  */
 
-static struct device_node *of_irq_find_parent(struct device_node *child)
+struct device_node *of_irq_find_parent_by_phandle(phandle p)
 {
-	struct device_node *p;
-	const phandle *parp;
-
-	if (!of_node_get(child))
-		return NULL;
-
-	do {
-		parp = of_get_property(child, "interrupt-parent", NULL);
-		if (parp == NULL)
-			p = of_get_parent(child);
-		else
-			p = of_find_node_by_phandle(*parp);
-		of_node_put(child);
-		child = p;
-	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
-
-	return p;
+	return of_find_node_by_phandle(p);
 }
 
 int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
@@ -783,7 +767,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
 			pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen);
 
 			/* Get the interrupt parent */
-			newpar = of_find_node_by_phandle((phandle)*imap);
+			newpar = of_irq_find_parent_by_phandle((phandle)*imap);
 			imap++;
 			--imaplen;
 
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 8362620..39e977d 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -685,29 +685,12 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
 static unsigned int of_irq_workarounds;
 static struct device_node *of_irq_dflt_pic;
 
-static struct device_node *of_irq_find_parent(struct device_node *child)
+struct device_node *of_irq_find_parent_by_phandle(phandle p)
 {
-	struct device_node *p;
-	const phandle *parp;
-
-	if (!of_node_get(child))
-		return NULL;
-
-	do {
-		parp = of_get_property(child, "interrupt-parent", NULL);
-		if (parp == NULL)
-			p = of_get_parent(child);
-		else {
-			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
-				p = of_node_get(of_irq_dflt_pic);
-			else
-				p = of_find_node_by_phandle(*parp);
-		}
-		of_node_put(child);
-		child = p;
-	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
+	if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
+		return of_node_get(of_irq_dflt_pic);
 
-	return p;
+	return of_find_node_by_phandle(p);
 }
 
 /* This doesn't need to be called if you don't have any special workaround
@@ -859,10 +842,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
 			DBG(" -> match=%d (imaplen=%d)\n", match, imaplen);
 
 			/* Get the interrupt parent */
-			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
-				newpar = of_node_get(of_irq_dflt_pic);
-			else
-				newpar = of_find_node_by_phandle((phandle)*imap);
+			newpar = of_irq_find_parent_by_phandle((phandle)*imap);
 			imap++;
 			--imaplen;
 
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 56ad1aa..ad569ca 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -24,6 +24,34 @@
 #include <linux/of_irq.h>
 #include <linux/string.h>
 
+/**
+ * of_irq_find_parent - Given a device node, find its interrupt parent node
+ * @child: pointer to device node
+ *
+ * Returns a pointer to the interrupt parent node, or NULL if the interrupt
+ * parent could not be determined.
+ */
+struct device_node *of_irq_find_parent(struct device_node *child)
+{
+	struct device_node *p;
+	const phandle *parp;
+
+	if (!of_node_get(child))
+		return NULL;
+
+	do {
+		parp = of_get_property(child, "interrupt-parent", NULL);
+		if (parp == NULL)
+			p = of_get_parent(child);
+		else
+			p = of_irq_find_parent_by_phandle(*parp);
+		of_node_put(child);
+		child = p;
+	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
+
+	return p;
+}
+
 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
 {
 	struct of_irq oirq;
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 0e37c05..f98b27b 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -30,6 +30,8 @@ struct of_irq {
 	u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
 };
 
+extern struct device_node *of_irq_find_parent_by_phandle(phandle p);
+extern struct device_node *of_irq_find_parent(struct device_node *child);
 extern int of_irq_map_one(struct device_node *device, int index,
 			  struct of_irq *out_irq);
 extern unsigned int irq_create_of_mapping(struct device_node *controller,

  reply	other threads:[~2010-06-04 21:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 21:21 [PATCH 1/5] of/irq: Move irq_of_parse_and_map() to common code Grant Likely
2010-06-04 21:21 ` Grant Likely [this message]
2010-06-10  6:38   ` [PATCH 3/5] of/irq: merge of_irq_find_parent() Benjamin Herrenschmidt
2010-06-21 21:11     ` Grant Likely
2010-06-04 21:21 ` [PATCH 4/5] of/irq: Merge of_irq_map_raw() Grant Likely
2010-06-10  6:38   ` Benjamin Herrenschmidt
2010-06-04 21:21 ` [PATCH 5/5] of/irq: merge of_irq_map_one() Grant Likely
2010-06-10  6:40   ` Benjamin Herrenschmidt
2010-06-10 23:36     ` Grant Likely
2010-06-11  1:17       ` Benjamin Herrenschmidt
2010-06-17 23:11         ` Grant Likely
2010-06-17 23:57           ` Benjamin Herrenschmidt
2010-06-18  0:39             ` Grant Likely
2010-06-11  1:30       ` PCIe bus seems work while 'dma' can't under linux jxnuxdy
2010-06-11  7:21         ` Benjamin Herrenschmidt
2010-06-15  7:05         ` jxnuxdy
2010-06-15  7:12           ` Benjamin Herrenschmidt
2010-06-10  6:33 ` [PATCH 1/5] of/irq: Move irq_of_parse_and_map() to common code Benjamin Herrenschmidt

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=20100604212145.10552.95452.stgit@angua \
    --to=grant.likely@secretlab.ca \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=microblaze-uclinux@itee.uq.edu.au \
    --cc=monstr@monstr.eu \
    --cc=sfr@canb.auug.org.au \
    /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).