Commit 2c8e65b5 authored by Rob Herring's avatar Rob Herring Committed by Michael Ellerman

powerpc: Use of_node_name_eq for node name comparisons

Convert string compares of DT node names to use of_node_name_eq helper
instead. This removes direct access to the node name pointer.

A couple of open coded iterating thru the child node names are converted
to use for_each_child_of_node() instead.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 0d1223dd
...@@ -400,8 +400,7 @@ void __init find_legacy_serial_ports(void) ...@@ -400,8 +400,7 @@ void __init find_legacy_serial_ports(void)
/* Next, fill our array with ISA ports */ /* Next, fill our array with ISA ports */
for_each_node_by_type(np, "serial") { for_each_node_by_type(np, "serial") {
struct device_node *isa = of_get_parent(np); struct device_node *isa = of_get_parent(np);
if (isa && (!strcmp(isa->name, "isa") || if (of_node_name_eq(isa, "isa") || of_node_name_eq(isa, "lpc")) {
!strcmp(isa->name, "lpc"))) {
if (of_device_is_available(np)) { if (of_device_is_available(np)) {
index = add_legacy_isa_port(np, isa); index = add_legacy_isa_port(np, isa);
if (index >= 0 && np == stdout) if (index >= 0 && np == stdout)
...@@ -415,11 +414,11 @@ void __init find_legacy_serial_ports(void) ...@@ -415,11 +414,11 @@ void __init find_legacy_serial_ports(void)
/* Next, try to locate PCI ports */ /* Next, try to locate PCI ports */
for (np = NULL; (np = of_find_all_nodes(np));) { for (np = NULL; (np = of_find_all_nodes(np));) {
struct device_node *pci, *parent = of_get_parent(np); struct device_node *pci, *parent = of_get_parent(np);
if (parent && !strcmp(parent->name, "isa")) { if (of_node_name_eq(parent, "isa")) {
of_node_put(parent); of_node_put(parent);
continue; continue;
} }
if (strcmp(np->name, "serial") && if (!of_node_name_eq(np, "serial") &&
!of_node_is_type(np, "serial")) { !of_node_is_type(np, "serial")) {
of_node_put(parent); of_node_put(parent);
continue; continue;
......
...@@ -179,9 +179,9 @@ static int pika_setup_leds(void) ...@@ -179,9 +179,9 @@ static int pika_setup_leds(void)
} }
for_each_child_of_node(np, child) for_each_child_of_node(np, child)
if (strcmp(child->name, "green") == 0) if (of_node_name_eq(child, "green"))
green_led = of_get_gpio(child, 0); green_led = of_get_gpio(child, 0);
else if (strcmp(child->name, "red") == 0) else if (of_node_name_eq(child, "red"))
red_led = of_get_gpio(child, 0); red_led = of_get_gpio(child, 0);
of_node_put(np); of_node_put(np);
......
...@@ -82,11 +82,9 @@ static void __init efika_pcisetup(void) ...@@ -82,11 +82,9 @@ static void __init efika_pcisetup(void)
return; return;
} }
for (pcictrl = NULL;;) { for_each_child_of_node(root, pcictrl)
pcictrl = of_get_next_child(root, pcictrl); if (of_node_name_eq(pcictrl, "pci"))
if ((pcictrl == NULL) || (strcmp(pcictrl->name, "pci") == 0))
break; break;
}
of_node_put(root); of_node_put(root);
......
...@@ -131,7 +131,7 @@ static int cell_setup_phb(struct pci_controller *phb) ...@@ -131,7 +131,7 @@ static int cell_setup_phb(struct pci_controller *phb)
np = phb->dn; np = phb->dn;
model = of_get_property(np, "model", NULL); model = of_get_property(np, "model", NULL);
if (model == NULL || strcmp(np->name, "pci")) if (model == NULL || !of_node_name_eq(np, "pci"))
return 0; return 0;
/* Setup workarounds for spider */ /* Setup workarounds for spider */
......
...@@ -458,7 +458,6 @@ static void init_affinity_node(int cbe) ...@@ -458,7 +458,6 @@ static void init_affinity_node(int cbe)
struct device_node *vic_dn, *last_spu_dn; struct device_node *vic_dn, *last_spu_dn;
phandle avoid_ph; phandle avoid_ph;
const phandle *vic_handles; const phandle *vic_handles;
const char *name;
int lenp, i, added; int lenp, i, added;
last_spu = list_first_entry(&cbe_spu_info[cbe].spus, struct spu, last_spu = list_first_entry(&cbe_spu_info[cbe].spus, struct spu,
...@@ -480,12 +479,7 @@ static void init_affinity_node(int cbe) ...@@ -480,12 +479,7 @@ static void init_affinity_node(int cbe)
if (!vic_dn) if (!vic_dn)
continue; continue;
/* a neighbour might be spe, mic-tm, or bif0 */ if (of_node_name_eq(vic_dn, "spe") ) {
name = of_get_property(vic_dn, "name", NULL);
if (!name)
continue;
if (strcmp(name, "spe") == 0) {
spu = devnode_spu(cbe, vic_dn); spu = devnode_spu(cbe, vic_dn);
avoid_ph = last_spu_dn->phandle; avoid_ph = last_spu_dn->phandle;
} else { } else {
...@@ -498,7 +492,7 @@ static void init_affinity_node(int cbe) ...@@ -498,7 +492,7 @@ static void init_affinity_node(int cbe)
spu = neighbour_spu(cbe, vic_dn, last_spu_dn); spu = neighbour_spu(cbe, vic_dn, last_spu_dn);
if (!spu) if (!spu)
continue; continue;
if (!strcmp(name, "mic-tm")) { if (of_node_name_eq(vic_dn, "mic-tm")) {
last_spu->has_mem_affinity = 1; last_spu->has_mem_affinity = 1;
spu->has_mem_affinity = 1; spu->has_mem_affinity = 1;
} }
......
...@@ -287,10 +287,7 @@ static __init void chrp_init(void) ...@@ -287,10 +287,7 @@ static __init void chrp_init(void)
* or /pci@80000000/isa@C/serial@i2F8 * or /pci@80000000/isa@C/serial@i2F8
* The optional graphics card has also type 'serial' in VGA mode. * The optional graphics card has also type 'serial' in VGA mode.
*/ */
property = of_get_property(node, "name", NULL); if (of_node_name_eq(node, "failsafe") || of_node_name_eq(node, "serial"))
if (!property)
goto out_put;
if (!strcmp(property, "failsafe") || !strcmp(property, "serial"))
add_preferred_console("ttyS", 0, NULL); add_preferred_console("ttyS", 0, NULL);
out_put: out_put:
of_node_put(node); of_node_put(node);
......
...@@ -173,9 +173,9 @@ static long ohare_htw_scc_enable(struct device_node *node, long param, ...@@ -173,9 +173,9 @@ static long ohare_htw_scc_enable(struct device_node *node, long param,
macio = macio_find(node, 0); macio = macio_find(node, 0);
if (!macio) if (!macio)
return -ENODEV; return -ENODEV;
if (!strcmp(node->name, "ch-a")) if (of_node_name_eq(node, "ch-a"))
chan_mask = MACIO_FLAG_SCCA_ON; chan_mask = MACIO_FLAG_SCCA_ON;
else if (!strcmp(node->name, "ch-b")) else if (of_node_name_eq(node, "ch-b"))
chan_mask = MACIO_FLAG_SCCB_ON; chan_mask = MACIO_FLAG_SCCB_ON;
else else
return -ENODEV; return -ENODEV;
...@@ -610,9 +610,9 @@ static long core99_scc_enable(struct device_node *node, long param, long value) ...@@ -610,9 +610,9 @@ static long core99_scc_enable(struct device_node *node, long param, long value)
macio = macio_find(node, 0); macio = macio_find(node, 0);
if (!macio) if (!macio)
return -ENODEV; return -ENODEV;
if (!strcmp(node->name, "ch-a")) if (of_node_name_eq(node, "ch-a"))
chan_mask = MACIO_FLAG_SCCA_ON; chan_mask = MACIO_FLAG_SCCA_ON;
else if (!strcmp(node->name, "ch-b")) else if (of_node_name_eq(node, "ch-b"))
chan_mask = MACIO_FLAG_SCCB_ON; chan_mask = MACIO_FLAG_SCCB_ON;
else else
return -ENODEV; return -ENODEV;
...@@ -1392,8 +1392,7 @@ static long g5_mpic_enable(struct device_node *node, long param, long value) ...@@ -1392,8 +1392,7 @@ static long g5_mpic_enable(struct device_node *node, long param, long value)
if (parent == NULL) if (parent == NULL)
return 0; return 0;
is_u3 = strcmp(parent->name, "u3") == 0 || is_u3 = of_node_name_eq(parent, "u3") || of_node_name_eq(parent, "u4");
strcmp(parent->name, "u4") == 0;
of_node_put(parent); of_node_put(parent);
if (!is_u3) if (!is_u3)
return 0; return 0;
......
...@@ -617,7 +617,7 @@ static void __init kw_i2c_probe(void) ...@@ -617,7 +617,7 @@ static void __init kw_i2c_probe(void)
* but not for now * but not for now
*/ */
child = of_get_next_child(np, NULL); child = of_get_next_child(np, NULL);
multibus = !child || strcmp(child->name, "i2c-bus"); multibus = !of_node_name_eq(child, "i2c-bus");
of_node_put(child); of_node_put(child);
/* For a multibus setup, we get the bus count based on the /* For a multibus setup, we get the bus count based on the
...@@ -1205,7 +1205,7 @@ static void pmac_i2c_devscan(void (*callback)(struct device_node *dev, ...@@ -1205,7 +1205,7 @@ static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
if (bus != pmac_i2c_find_bus(np)) if (bus != pmac_i2c_find_bus(np))
continue; continue;
for (p = whitelist; p->name != NULL; p++) { for (p = whitelist; p->name != NULL; p++) {
if (strcmp(np->name, p->name)) if (!of_node_name_eq(np, p->name))
continue; continue;
if (p->compatible && if (p->compatible &&
!of_device_is_compatible(np, p->compatible)) !of_device_is_compatible(np, p->compatible))
......
...@@ -501,9 +501,7 @@ static void __init init_p2pbridge(void) ...@@ -501,9 +501,7 @@ static void __init init_p2pbridge(void)
/* XXX it would be better here to identify the specific /* XXX it would be better here to identify the specific
PCI-PCI bridge chip we have. */ PCI-PCI bridge chip we have. */
p2pbridge = of_find_node_by_name(NULL, "pci-bridge"); p2pbridge = of_find_node_by_name(NULL, "pci-bridge");
if (p2pbridge == NULL if (p2pbridge == NULL || !of_node_name_eq(p2pbridge->parent, "pci"))
|| p2pbridge->parent == NULL
|| strcmp(p2pbridge->parent->name, "pci") != 0)
goto done; goto done;
if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) { if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) {
DBG("Can't find PCI infos for PCI<->PCI bridge\n"); DBG("Can't find PCI infos for PCI<->PCI bridge\n");
...@@ -828,14 +826,14 @@ static int __init pmac_add_bridge(struct device_node *dev) ...@@ -828,14 +826,14 @@ static int __init pmac_add_bridge(struct device_node *dev)
if (of_device_is_compatible(dev, "uni-north")) { if (of_device_is_compatible(dev, "uni-north")) {
primary = setup_uninorth(hose, &rsrc); primary = setup_uninorth(hose, &rsrc);
disp_name = "UniNorth"; disp_name = "UniNorth";
} else if (strcmp(dev->name, "pci") == 0) { } else if (of_node_name_eq(dev, "pci")) {
/* XXX assume this is a mpc106 (grackle) */ /* XXX assume this is a mpc106 (grackle) */
setup_grackle(hose); setup_grackle(hose);
disp_name = "Grackle (MPC106)"; disp_name = "Grackle (MPC106)";
} else if (strcmp(dev->name, "bandit") == 0) { } else if (of_node_name_eq(dev, "bandit")) {
setup_bandit(hose, &rsrc); setup_bandit(hose, &rsrc);
disp_name = "Bandit"; disp_name = "Bandit";
} else if (strcmp(dev->name, "chaos") == 0) { } else if (of_node_name_eq(dev, "chaos")) {
setup_chaos(hose, &rsrc); setup_chaos(hose, &rsrc);
disp_name = "Chaos"; disp_name = "Chaos";
primary = 0; primary = 0;
...@@ -914,16 +912,14 @@ void __init pmac_pci_init(void) ...@@ -914,16 +912,14 @@ void __init pmac_pci_init(void)
"of device tree\n"); "of device tree\n");
return; return;
} }
for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) { for_each_child_of_node(root, np) {
if (np->name == NULL) if (of_node_name_eq(np, "bandit")
continue; || of_node_name_eq(np, "chaos")
if (strcmp(np->name, "bandit") == 0 || of_node_name_eq(np, "pci")) {
|| strcmp(np->name, "chaos") == 0
|| strcmp(np->name, "pci") == 0) {
if (pmac_add_bridge(np) == 0) if (pmac_add_bridge(np) == 0)
of_node_get(np); of_node_get(np);
} }
if (strcmp(np->name, "ht") == 0) { if (of_node_name_eq(np, "ht")) {
of_node_get(np); of_node_get(np);
ht = np; ht = np;
} }
...@@ -983,7 +979,7 @@ static bool pmac_pci_enable_device_hook(struct pci_dev *dev) ...@@ -983,7 +979,7 @@ static bool pmac_pci_enable_device_hook(struct pci_dev *dev)
/* Firewire & GMAC were disabled after PCI probe, the driver is /* Firewire & GMAC were disabled after PCI probe, the driver is
* claiming them, we must re-enable them now. * claiming them, we must re-enable them now.
*/ */
if (uninorth_child && !strcmp(node->name, "firewire") && if (uninorth_child && of_node_name_eq(node, "firewire") &&
(of_device_is_compatible(node, "pci106b,18") || (of_device_is_compatible(node, "pci106b,18") ||
of_device_is_compatible(node, "pci106b,30") || of_device_is_compatible(node, "pci106b,30") ||
of_device_is_compatible(node, "pci11c1,5811"))) { of_device_is_compatible(node, "pci11c1,5811"))) {
...@@ -991,7 +987,7 @@ static bool pmac_pci_enable_device_hook(struct pci_dev *dev) ...@@ -991,7 +987,7 @@ static bool pmac_pci_enable_device_hook(struct pci_dev *dev)
pmac_call_feature(PMAC_FTR_1394_ENABLE, node, 0, 1); pmac_call_feature(PMAC_FTR_1394_ENABLE, node, 0, 1);
updatecfg = 1; updatecfg = 1;
} }
if (uninorth_child && !strcmp(node->name, "ethernet") && if (uninorth_child && of_node_name_eq(node, "ethernet") &&
of_device_is_compatible(node, "gmac")) { of_device_is_compatible(node, "gmac")) {
pmac_call_feature(PMAC_FTR_GMAC_ENABLE, node, 0, 1); pmac_call_feature(PMAC_FTR_GMAC_ENABLE, node, 0, 1);
updatecfg = 1; updatecfg = 1;
...@@ -1262,4 +1258,3 @@ struct pci_controller_ops pmac_pci_controller_ops = { ...@@ -1262,4 +1258,3 @@ struct pci_controller_ops pmac_pci_controller_ops = {
.enable_device_hook = pmac_pci_enable_device_hook, .enable_device_hook = pmac_pci_enable_device_hook,
#endif #endif
}; };
...@@ -101,9 +101,8 @@ static void macio_gpio_init_one(struct macio_chip *macio) ...@@ -101,9 +101,8 @@ static void macio_gpio_init_one(struct macio_chip *macio)
* Find the "gpio" parent node * Find the "gpio" parent node
*/ */
for (gparent = NULL; for_each_child_of_node(macio->of_node, gparent)
(gparent = of_get_next_child(macio->of_node, gparent)) != NULL;) if (of_node_name_eq(gparent, "gpio"))
if (strcmp(gparent->name, "gpio") == 0)
break; break;
if (gparent == NULL) if (gparent == NULL)
return; return;
...@@ -313,7 +312,7 @@ static void uninorth_install_pfunc(void) ...@@ -313,7 +312,7 @@ static void uninorth_install_pfunc(void)
* Install handlers for the hwclock child if any * Install handlers for the hwclock child if any
*/ */
for (np = NULL; (np = of_get_next_child(uninorth_node, np)) != NULL;) for (np = NULL; (np = of_get_next_child(uninorth_node, np)) != NULL;)
if (strcmp(np->name, "hw-clock") == 0) { if (of_node_name_eq(np, "hw-clock")) {
unin_hwclock = np; unin_hwclock = np;
break; break;
} }
......
...@@ -553,13 +553,13 @@ void __init pmac_pic_init(void) ...@@ -553,13 +553,13 @@ void __init pmac_pic_init(void)
for_each_node_with_property(np, "interrupt-controller") { for_each_node_with_property(np, "interrupt-controller") {
/* Skip /chosen/interrupt-controller */ /* Skip /chosen/interrupt-controller */
if (strcmp(np->name, "chosen") == 0) if (of_node_name_eq(np, "chosen"))
continue; continue;
/* It seems like at least one person wants /* It seems like at least one person wants
* to use BootX on a machine with an AppleKiwi * to use BootX on a machine with an AppleKiwi
* controller which happens to pretend to be an * controller which happens to pretend to be an
* interrupt controller too. */ * interrupt controller too. */
if (strcmp(np->name, "AppleKiwi") == 0) if (of_node_name_eq(np, "AppleKiwi"))
continue; continue;
/* I think we found one ! */ /* I think we found one ! */
of_irq_dflt_pic = np; of_irq_dflt_pic = np;
......
...@@ -560,15 +560,9 @@ static int __init check_pmac_serial_console(void) ...@@ -560,15 +560,9 @@ static int __init check_pmac_serial_console(void)
} }
pr_debug("stdout is %pOF\n", prom_stdout); pr_debug("stdout is %pOF\n", prom_stdout);
name = of_get_property(prom_stdout, "name", NULL); if (of_node_name_eq(prom_stdout, "ch-a"))
if (!name) {
pr_debug(" stdout package has no name !\n");
goto not_found;
}
if (strcmp(name, "ch-a") == 0)
offset = 0; offset = 0;
else if (strcmp(name, "ch-b") == 0) else if (of_node_name_eq(prom_stdout, "ch-b"))
offset = 1; offset = 1;
else else
goto not_found; goto not_found;
......
...@@ -87,7 +87,7 @@ void udbg_scc_init(int force_scc) ...@@ -87,7 +87,7 @@ void udbg_scc_init(int force_scc)
for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) { for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) {
if (ch == stdout) if (ch == stdout)
ch_def = of_node_get(ch); ch_def = of_node_get(ch);
if (strcmp(ch->name, "ch-a") == 0) if (of_node_name_eq(ch, "ch-a"))
ch_a = of_node_get(ch); ch_a = of_node_get(ch);
} }
if (ch_def == NULL && !force_scc) if (ch_def == NULL && !force_scc)
......
...@@ -877,7 +877,7 @@ static int __init opal_init(void) ...@@ -877,7 +877,7 @@ static int __init opal_init(void)
consoles = of_find_node_by_path("/ibm,opal/consoles"); consoles = of_find_node_by_path("/ibm,opal/consoles");
if (consoles) { if (consoles) {
for_each_child_of_node(consoles, np) { for_each_child_of_node(consoles, np) {
if (strcmp(np->name, "serial")) if (!of_node_name_eq(np, "serial"))
continue; continue;
of_platform_device_create(np, NULL, NULL); of_platform_device_create(np, NULL, NULL);
} }
......
...@@ -190,7 +190,7 @@ static void __init pseries_setup_i8259_cascade(void) ...@@ -190,7 +190,7 @@ static void __init pseries_setup_i8259_cascade(void)
of_node_put(old); of_node_put(old);
if (np == NULL) if (np == NULL)
break; break;
if (strcmp(np->name, "pci") != 0) if (!of_node_name_eq(np, "pci"))
continue; continue;
addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL); addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL);
if (addrp == NULL) if (addrp == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment