of: Migrate of_find_node_by_name() users to for_each_node_by_name()
There are a bunch of users open coding the for_each_node_by_name() by calling of_find_node_by_name() directly instead of using the macro. This is getting in the way of some cleanups, and the possibility of removing of_find_node_by_name() entirely. Clean it up so that all the users are consistent. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -2805,25 +2805,20 @@ set_initial_features(void)
|
||||
/* Enable GMAC for now for PCI probing. It will be disabled
|
||||
* later on after PCI probe
|
||||
*/
|
||||
np = of_find_node_by_name(NULL, "ethernet");
|
||||
while(np) {
|
||||
for_each_node_by_name(np, "ethernet")
|
||||
if (of_device_is_compatible(np, "K2-GMAC"))
|
||||
g5_gmac_enable(np, 0, 1);
|
||||
np = of_find_node_by_name(np, "ethernet");
|
||||
}
|
||||
|
||||
/* Enable FW before PCI probe. Will be disabled later on
|
||||
* Note: We should have a batter way to check that we are
|
||||
* dealing with uninorth internal cell and not a PCI cell
|
||||
* on the external PCI. The code below works though.
|
||||
*/
|
||||
np = of_find_node_by_name(NULL, "firewire");
|
||||
while(np) {
|
||||
for_each_node_by_name(np, "firewire") {
|
||||
if (of_device_is_compatible(np, "pci106b,5811")) {
|
||||
macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
|
||||
g5_fw_enable(np, 0, 1);
|
||||
}
|
||||
np = of_find_node_by_name(np, "firewire");
|
||||
}
|
||||
}
|
||||
#else /* CONFIG_POWER4 */
|
||||
@@ -2834,13 +2829,11 @@ set_initial_features(void)
|
||||
/* Enable GMAC for now for PCI probing. It will be disabled
|
||||
* later on after PCI probe
|
||||
*/
|
||||
np = of_find_node_by_name(NULL, "ethernet");
|
||||
while(np) {
|
||||
for_each_node_by_name(np, "ethernet") {
|
||||
if (np->parent
|
||||
&& of_device_is_compatible(np->parent, "uni-north")
|
||||
&& of_device_is_compatible(np, "gmac"))
|
||||
core99_gmac_enable(np, 0, 1);
|
||||
np = of_find_node_by_name(np, "ethernet");
|
||||
}
|
||||
|
||||
/* Enable FW before PCI probe. Will be disabled later on
|
||||
@@ -2848,8 +2841,7 @@ set_initial_features(void)
|
||||
* dealing with uninorth internal cell and not a PCI cell
|
||||
* on the external PCI. The code below works though.
|
||||
*/
|
||||
np = of_find_node_by_name(NULL, "firewire");
|
||||
while(np) {
|
||||
for_each_node_by_name(np, "firewire") {
|
||||
if (np->parent
|
||||
&& of_device_is_compatible(np->parent, "uni-north")
|
||||
&& (of_device_is_compatible(np, "pci106b,18") ||
|
||||
@@ -2858,18 +2850,16 @@ set_initial_features(void)
|
||||
macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
|
||||
core99_firewire_enable(np, 0, 1);
|
||||
}
|
||||
np = of_find_node_by_name(np, "firewire");
|
||||
}
|
||||
|
||||
/* Enable ATA-100 before PCI probe. */
|
||||
np = of_find_node_by_name(NULL, "ata-6");
|
||||
while(np) {
|
||||
for_each_node_by_name(np, "ata-6") {
|
||||
if (np->parent
|
||||
&& of_device_is_compatible(np->parent, "uni-north")
|
||||
&& of_device_is_compatible(np, "kauai-ata")) {
|
||||
core99_ata100_enable(np, 1);
|
||||
}
|
||||
np = of_find_node_by_name(np, "ata-6");
|
||||
}
|
||||
|
||||
/* Switch airport off */
|
||||
|
@@ -698,7 +698,7 @@ static void __init fixup_nec_usb2(void)
|
||||
{
|
||||
struct device_node *nec;
|
||||
|
||||
for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
|
||||
for_each_node_by_name(nec, "usb") {
|
||||
struct pci_controller *hose;
|
||||
u32 data;
|
||||
const u32 *prop;
|
||||
|
@@ -577,7 +577,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
|
||||
int ok;
|
||||
|
||||
/* Look for the clock chip */
|
||||
while ((cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL) {
|
||||
for_each_node_by_name(cc, "i2c-hwclock") {
|
||||
p = of_get_parent(cc);
|
||||
ok = p && of_device_is_compatible(p, "uni-n-i2c");
|
||||
of_node_put(p);
|
||||
|
@@ -191,7 +191,7 @@ int __init udbg_adb_init(int force_btext)
|
||||
* of type "adb". If not, we return a failure, but we keep the
|
||||
* bext output set for now
|
||||
*/
|
||||
for (np = NULL; (np = of_find_node_by_name(np, "keyboard")) != NULL;) {
|
||||
for_each_node_by_name(np, "keyboard") {
|
||||
struct device_node *parent = of_get_parent(np);
|
||||
int found = (parent && strcmp(parent->type, "adb") == 0);
|
||||
of_node_put(parent);
|
||||
|
Reference in New Issue
Block a user