linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: linuxppc-dev@ozlabs.org
Cc: scottwood@freescale.com,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	arnd@arndb.de
Subject: [PATCH] powerpc: reduce code duplication in legacy_serial, add UART parent types
Date: Thu, 24 Jan 2008 12:13:02 -0500	[thread overview]
Message-ID: <12011947821738-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <200801172335.48817.arnd@arndb.de>

The legacy_serial was treating each UART parent in a separate code block.
Rather than continue this trend for the new parent IDs, this condenses
all (soc, tsi, opb, plus two more new types) into one of_device_id array.
The new types are wrs,epld-localbus for the Wind River sbc8560, and a
more generic "simple-bus" as requested by Scott Wood.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 arch/powerpc/kernel/legacy_serial.c |   45 +++++++++++++---------------------
 1 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 4bfff88..523a9d4 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -4,6 +4,7 @@
 #include <linux/serial_core.h>
 #include <linux/console.h>
 #include <linux/pci.h>
+#include <linux/of_device.h>
 #include <asm/io.h>
 #include <asm/mmu.h>
 #include <asm/prom.h>
@@ -31,6 +32,15 @@ static struct legacy_serial_info {
 	int				irq_check_parent;
 	phys_addr_t			taddr;
 } legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS];
+
+static struct __init of_device_id parents[] = {
+	{.type = "soc",},
+	{.type = "tsi-bridge",},
+	{.type = "opb", .compatible = "ibm,opb",},
+	{.compatible = "simple-bus",},
+	{.compatible = "wrs,epld-localbus",},
+};
+
 static unsigned int legacy_serial_count;
 static int legacy_serial_console = -1;
 
@@ -306,18 +316,20 @@ void __init find_legacy_serial_ports(void)
 		DBG(" no linux,stdout-path !\n");
 	}
 
-	/* First fill our array with SOC ports */
+	/* Iterate over all the 16550 ports, looking for known parents */
 	for_each_compatible_node(np, "serial", "ns16550") {
-		struct device_node *soc = of_get_parent(np);
-		if (soc && !strcmp(soc->type, "soc")) {
+		struct device_node *parent = of_get_parent(np);
+		if (!parent)
+			continue;
+		if (of_match_node(parents, parent) != NULL) {
 			index = add_legacy_soc_port(np, np);
 			if (index >= 0 && np == stdout)
 				legacy_serial_console = index;
 		}
-		of_node_put(soc);
+		of_node_put(parent);
 	}
 
-	/* First fill our array with ISA ports */
+	/* Next, fill our array with ISA ports */
 	for_each_node_by_type(np, "serial") {
 		struct device_node *isa = of_get_parent(np);
 		if (isa && !strcmp(isa->name, "isa")) {
@@ -328,29 +340,6 @@ void __init find_legacy_serial_ports(void)
 		of_node_put(isa);
 	}
 
-	/* First fill our array with tsi-bridge ports */
-	for_each_compatible_node(np, "serial", "ns16550") {
-		struct device_node *tsi = of_get_parent(np);
-		if (tsi && !strcmp(tsi->type, "tsi-bridge")) {
-			index = add_legacy_soc_port(np, np);
-			if (index >= 0 && np == stdout)
-				legacy_serial_console = index;
-		}
-		of_node_put(tsi);
-	}
-
-	/* First fill our array with opb bus ports */
-	for_each_compatible_node(np, "serial", "ns16550") {
-		struct device_node *opb = of_get_parent(np);
-		if (opb && (!strcmp(opb->type, "opb") ||
-			    of_device_is_compatible(opb, "ibm,opb"))) {
-			index = add_legacy_soc_port(np, np);
-			if (index >= 0 && np == stdout)
-				legacy_serial_console = index;
-		}
-		of_node_put(opb);
-	}
-
 #ifdef CONFIG_PCI
 	/* Next, try to locate PCI ports */
 	for (np = NULL; (np = of_find_all_nodes(np));) {
-- 
1.5.0.rc1.gf4b6c

  reply	other threads:[~2008-01-24 17:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-07 14:25 [PATCH 0/7] Powerpc support for SBC8560 board Paul Gortmaker
     [not found] ` <ef7d84e06c45289f51f35845ccaa63bbf31827db.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25   ` [PATCH 1/7] powerpc: use for_each in legacy_serial Paul Gortmaker
     [not found]   ` <f6302303b90b7e1516a1f61d85f1eafd51ec3b51.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 2/7] powerpc: allow localbus compatible serial ports for console device Paul Gortmaker
2008-01-07 14:33       ` Arnd Bergmann
2008-01-07 15:33         ` Paul Gortmaker
2008-01-07 16:04           ` Arnd Bergmann
2008-01-17 22:03             ` Paul Gortmaker
2008-01-17 22:07               ` Scott Wood
2008-01-17 22:35               ` Arnd Bergmann
2008-01-24 17:13                 ` Paul Gortmaker [this message]
2008-01-24 22:40                   ` [PATCH] powerpc: reduce code duplication in legacy_serial, add UART parent types Paul Gortmaker
2008-01-25  8:17                     ` Kumar Gala
2008-07-07  6:33                       ` Benjamin Herrenschmidt
2008-07-07 15:02                         ` Paul Gortmaker
2008-07-07 15:05                         ` [PATCH] legacy-serial: more meaningful names, terminate array Paul Gortmaker
2008-07-07 22:17                           ` Benjamin Herrenschmidt
2008-07-07 22:42                             ` [PATCH] ibmebus: more meaningful variable name Paul Gortmaker
2008-01-25  6:17                   ` [PATCH] powerpc: reduce code duplication in legacy_serial, add UART parent types Arnd Bergmann
     [not found]   ` <2e29068028918298af42b5ed07f7db147b81c921.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 3/7] sbc8560: add support for Wind River SBC8560 in arch/powerpc Paul Gortmaker
2008-01-08  0:32       ` Stephen Rothwell
2008-01-09  4:39         ` Paul Gortmaker
2008-01-09  6:23           ` Stephen Rothwell
     [not found]   ` <d10d083bafb978936975111f09669120201072ec.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 4/7] sbc8560: Add device tree source for Wind River SBC8560 board Paul Gortmaker
2008-01-10  2:56     ` David Gibson
2008-01-15 14:12       ` Kumar Gala
2008-01-17 20:50       ` Paul Gortmaker
     [not found]   ` <51ce902057aacef795405f501ad482c744a2e1f2.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 5/7] sbc8560: Convert WRS SBC8560 device tree to v1 format Paul Gortmaker
     [not found]   ` <25caba2d31cd9404db085c69e4d449dabbe56f1f.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 6/7] CPM2: Make support for the CPM2 optional on 8560 based boards Paul Gortmaker
     [not found]   ` <20d9f56839785af8a445e4cef3db98430b84b4ce.1199715362.git.paul.gortmaker@windriver.com>
2008-01-07 14:25     ` [PATCH 7/7] sbc8560: Add default .config file for Wind River SBC8560 Paul Gortmaker
2008-01-24  9:30 ` [PATCH 0/7] Powerpc support for SBC8560 board Kumar Gala
2008-01-24 14:17   ` Paul Gortmaker
2008-01-24 14:25     ` Kumar Gala
2008-01-24 14:27       ` Paul Gortmaker

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=12011947821738-git-send-email-paul.gortmaker@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=arnd@arndb.de \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.com \
    /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).