From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756504AbXKUUKl (ORCPT ); Wed, 21 Nov 2007 15:10:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753280AbXKUUKJ (ORCPT ); Wed, 21 Nov 2007 15:10:09 -0500 Received: from nf-out-0910.google.com ([64.233.182.190]:18867 "EHLO nf-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752824AbXKUUKF (ORCPT ); Wed, 21 Nov 2007 15:10:05 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:cc:subject:message-id:mime-version:content-type:content-disposition:user-agent; b=rsTAAaw1JVT+RZI+D+XZR9GX5JlrULP2xL5EzNcV2v2yD/lR4vO0L1hdUTkXa4Fw13H3YUzg5GO66AvP6tnxoh6mv7o9inFE48Ik759N0nmi/H7crtAWci3j22OS42ZxjriEA3chtM4CYIjoy7YTxPZdodBWfd3JovPiiIW7oGk= Date: Wed, 21 Nov 2007 23:09:54 +0300 From: Cyrill Gorcunov To: PPCML Cc: Kumar Gala , LKML , Paul Mackerras Subject: [RFC] PPC: convert for(...) cycles into for_each... form Message-ID: <20071121200954.GB7273@cvg> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org From: Cyrill Gorcunov This patch does convert cyclic calls to of_find_compatible_node() and of_find_node_by_type() into appropriate macroses. It does reduce code a bit. Signed-off-by: Cyrill Gorcunov --- WARNING: I've no PowerPC to test it - please reiew the patch closely. Thanks. arch/powerpc/kernel/legacy_serial.c | 8 ++++---- arch/powerpc/platforms/82xx/pq2.c | 4 ++-- arch/powerpc/platforms/celleb/scc_sio.c | 5 ++--- arch/powerpc/platforms/powermac/low_i2c.c | 3 +-- arch/powerpc/sysdev/mv64x60_pci.c | 4 ++-- arch/powerpc/sysdev/mv64x60_udbg.c | 4 ++-- arch/powerpc/sysdev/uic.c | 17 +++++------------ 7 files changed, 18 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c index 4ed5887..b5dc646 100644 --- a/arch/powerpc/kernel/legacy_serial.c +++ b/arch/powerpc/kernel/legacy_serial.c @@ -307,7 +307,7 @@ void __init find_legacy_serial_ports(void) } /* First fill our array with SOC ports */ - for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) { + for_each_compatible_node(np, "serial", "ns16550") { struct device_node *soc = of_get_parent(np); if (soc && !strcmp(soc->type, "soc")) { index = add_legacy_soc_port(np, np); @@ -318,7 +318,7 @@ void __init find_legacy_serial_ports(void) } /* First fill our array with ISA ports */ - for (np = NULL; (np = of_find_node_by_type(np, "serial"));) { + for_each_node_by_type(np, "serial") { struct device_node *isa = of_get_parent(np); if (isa && !strcmp(isa->name, "isa")) { index = add_legacy_isa_port(np, isa); @@ -329,7 +329,7 @@ void __init find_legacy_serial_ports(void) } /* First fill our array with tsi-bridge ports */ - for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) { + 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); @@ -340,7 +340,7 @@ void __init find_legacy_serial_ports(void) } /* First fill our array with opb bus ports */ - for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16550")) != NULL;) { + 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"))) { diff --git a/arch/powerpc/platforms/82xx/pq2.c b/arch/powerpc/platforms/82xx/pq2.c index a497cba..9e74393 100644 --- a/arch/powerpc/platforms/82xx/pq2.c +++ b/arch/powerpc/platforms/82xx/pq2.c @@ -72,11 +72,11 @@ err: void __init pq2_init_pci(void) { - struct device_node *np = NULL; + struct device_node *np; ppc_md.pci_exclude_device = pq2_pci_exclude_device; - while ((np = of_find_compatible_node(np, NULL, "fsl,pq2-pci"))) + for_each_compatible_node(np, NULL, "fsl,pq2-pci") pq2_pci_add_bridge(np); } #endif diff --git a/arch/powerpc/platforms/celleb/scc_sio.c b/arch/powerpc/platforms/celleb/scc_sio.c index 6100082..5e43bac 100644 --- a/arch/powerpc/platforms/celleb/scc_sio.c +++ b/arch/powerpc/platforms/celleb/scc_sio.c @@ -42,14 +42,13 @@ static struct { static int __init txx9_serial_init(void) { extern int early_serial_txx9_setup(struct uart_port *port); - struct device_node *node = NULL; + struct device_node *node; int i; struct uart_port req; struct of_irq irq; struct resource res; - while ((node = of_find_compatible_node(node, - "serial", "toshiba,sio-scc")) != NULL) { + for_each_compatible_node(node, "serial", "toshiba,sio-scc") { for (i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) { if (!(txx9_serial_bitmap & (1<full_name); irq_set_default_host(primary_uic->irqhost); of_node_put(np); /* The scan again for cascaded UICs */ - np = of_find_compatible_node(NULL, NULL, "ibm,uic"); - while (np) { + for_each_compatible_node(np, NULL, "ibm,uic") { interrupts = of_get_property(np, "interrupts", NULL); if (interrupts) { /* Secondary UIC */ @@ -355,7 +350,7 @@ void __init uic_init_tree(void) int ret; uic = uic_init_one(np); - if (! uic) + if (!uic) panic("Unable to initialize a secondary UIC %s\n", np->full_name); @@ -373,8 +368,6 @@ void __init uic_init_tree(void) /* FIXME: setup critical cascade?? */ } - - np = of_find_compatible_node(np, NULL, "ibm,uic"); } }