aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/prom.c19
-rw-r--r--arch/powerpc/kernel/vio.c3
-rw-r--r--arch/powerpc/platforms/chrp/pci.c6
-rw-r--r--arch/powerpc/platforms/chrp/setup.c9
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c7
-rw-r--r--arch/powerpc/platforms/powermac/feature.c45
-rw-r--r--arch/powerpc/platforms/powermac/pci.c23
-rw-r--r--arch/powerpc/platforms/powermac/setup.c25
-rw-r--r--arch/powerpc/platforms/powermac/smp.c5
-rw-r--r--drivers/macintosh/ans-lcd.c9
-rw-r--r--drivers/macintosh/via-pmu.c4
-rw-r--r--drivers/media/video/planb.c5
-rw-r--r--drivers/serial/pmac_zilog.c4
-rw-r--r--drivers/video/controlfb.c16
-rw-r--r--include/asm-powerpc/prom.h3
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c90
-rw-r--r--sound/oss/dmasound/tas_common.c5
-rw-r--r--sound/ppc/pmac.c27
-rw-r--r--sound/ppc/tumbler.c35
19 files changed, 206 insertions, 134 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 860c88b2f6d1..caef555f2dc0 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1072,25 +1072,6 @@ int of_n_size_cells(struct device_node* np)
1072} 1072}
1073EXPORT_SYMBOL(of_n_size_cells); 1073EXPORT_SYMBOL(of_n_size_cells);
1074 1074
1075/**
1076 * Construct and return a list of the device_nodes with a given name.
1077 */
1078struct device_node *find_devices(const char *name)
1079{
1080 struct device_node *head, **prevp, *np;
1081
1082 prevp = &head;
1083 for (np = allnodes; np != 0; np = np->allnext) {
1084 if (np->name != 0 && strcasecmp(np->name, name) == 0) {
1085 *prevp = np;
1086 prevp = &np->next;
1087 }
1088 }
1089 *prevp = NULL;
1090 return head;
1091}
1092EXPORT_SYMBOL(find_devices);
1093
1094/** Checks if the given "compat" string matches one of the strings in 1075/** Checks if the given "compat" string matches one of the strings in
1095 * the device's "compatible" property 1076 * the device's "compatible" property
1096 */ 1077 */
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index a09277a8639f..9eaefac5053f 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -308,7 +308,7 @@ static int __init vio_bus_init(void)
308 return err; 308 return err;
309 } 309 }
310 310
311 node_vroot = find_devices("vdevice"); 311 node_vroot = of_find_node_by_name(NULL, "vdevice");
312 if (node_vroot) { 312 if (node_vroot) {
313 struct device_node *of_node; 313 struct device_node *of_node;
314 314
@@ -322,6 +322,7 @@ static int __init vio_bus_init(void)
322 __FUNCTION__, of_node); 322 __FUNCTION__, of_node);
323 vio_register_device_node(of_node); 323 vio_register_device_node(of_node);
324 } 324 }
325 of_node_put(node_vroot);
325 } 326 }
326 327
327 return 0; 328 return 0;
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index de776e3889e3..1469d6478f67 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -136,9 +136,11 @@ hydra_init(void)
136 struct device_node *np; 136 struct device_node *np;
137 struct resource r; 137 struct resource r;
138 138
139 np = find_devices("mac-io"); 139 np = of_find_node_by_name(NULL, "mac-io");
140 if (np == NULL || of_address_to_resource(np, 0, &r)) 140 if (np == NULL || of_address_to_resource(np, 0, &r)) {
141 of_node_put(np);
141 return 0; 142 return 0;
143 }
142 Hydra = ioremap(r.start, r.end-r.start); 144 Hydra = ioremap(r.start, r.end-r.start);
143 printk("Hydra Mac I/O at %llx\n", (unsigned long long)r.start); 145 printk("Hydra Mac I/O at %llx\n", (unsigned long long)r.start);
144 printk("Hydra Feature_Control was %x", 146 printk("Hydra Feature_Control was %x",
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 9c1b231b1ff9..1870038a8e0a 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -468,7 +468,7 @@ static void __init chrp_find_8259(void)
468 * Also, Pegasos-type platforms don't have a proper node to start 468 * Also, Pegasos-type platforms don't have a proper node to start
469 * from anyway 469 * from anyway
470 */ 470 */
471 for (np = find_devices("pci"); np != NULL; np = np->next) { 471 for_each_node_by_name(np, "pci") {
472 const unsigned int *addrp = of_get_property(np, 472 const unsigned int *addrp = of_get_property(np,
473 "8259-interrupt-acknowledge", NULL); 473 "8259-interrupt-acknowledge", NULL);
474 474
@@ -477,6 +477,7 @@ static void __init chrp_find_8259(void)
477 chrp_int_ack = addrp[of_n_addr_cells(np)-1]; 477 chrp_int_ack = addrp[of_n_addr_cells(np)-1];
478 break; 478 break;
479 } 479 }
480 of_node_put(np);
480 if (np == NULL) 481 if (np == NULL)
481 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge" 482 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
482 " address, polling\n"); 483 " address, polling\n");
@@ -518,10 +519,11 @@ void __init chrp_init_IRQ(void)
518#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON) 519#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON)
519 /* see if there is a keyboard in the device tree 520 /* see if there is a keyboard in the device tree
520 with a parent of type "adb" */ 521 with a parent of type "adb" */
521 for (kbd = find_devices("keyboard"); kbd; kbd = kbd->next) 522 for_each_node_by_name(kbd, "keyboard")
522 if (kbd->parent && kbd->parent->type 523 if (kbd->parent && kbd->parent->type
523 && strcmp(kbd->parent->type, "adb") == 0) 524 && strcmp(kbd->parent->type, "adb") == 0)
524 break; 525 break;
526 of_node_put(kbd);
525 if (kbd) 527 if (kbd)
526 setup_irq(HYDRA_INT_ADB_NMI, &xmon_irqaction); 528 setup_irq(HYDRA_INT_ADB_NMI, &xmon_irqaction);
527#endif 529#endif
@@ -547,7 +549,7 @@ chrp_init2(void)
547 /* Get the event scan rate for the rtas so we know how 549 /* Get the event scan rate for the rtas so we know how
548 * often it expects a heartbeat. -- Cort 550 * often it expects a heartbeat. -- Cort
549 */ 551 */
550 device = find_devices("rtas"); 552 device = of_find_node_by_name(NULL, "rtas");
551 if (device) 553 if (device)
552 p = of_get_property(device, "rtas-event-scan-rate", NULL); 554 p = of_get_property(device, "rtas-event-scan-rate", NULL);
553 if (p && *p) { 555 if (p && *p) {
@@ -576,6 +578,7 @@ chrp_init2(void)
576 printk("RTAS Event Scan Rate: %u (%lu jiffies)\n", 578 printk("RTAS Event Scan Rate: %u (%lu jiffies)\n",
577 *p, interval); 579 *p, interval);
578 } 580 }
581 of_node_put(device);
579 582
580 if (ppc_md.progress) 583 if (ppc_md.progress)
581 ppc_md.progress(" Have fun! ", 0x7777); 584 ppc_md.progress(" Have fun! ", 0x7777);
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 0dc8a45c408a..d679964ae2ab 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -56,13 +56,16 @@ struct backlight_device *pmac_backlight;
56 56
57int pmac_has_backlight_type(const char *type) 57int pmac_has_backlight_type(const char *type)
58{ 58{
59 struct device_node* bk_node = find_devices("backlight"); 59 struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
60 60
61 if (bk_node) { 61 if (bk_node) {
62 const char *prop = of_get_property(bk_node, 62 const char *prop = of_get_property(bk_node,
63 "backlight-control", NULL); 63 "backlight-control", NULL);
64 if (prop && strncmp(prop, type, strlen(type)) == 0) 64 if (prop && strncmp(prop, type, strlen(type)) == 0) {
65 of_node_put(bk_node);
65 return 1; 66 return 1;
67 }
68 of_node_put(bk_node);
66 } 69 }
67 70
68 return 0; 71 return 0;
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 44f85507db3c..52cfdd86c928 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -2408,12 +2408,13 @@ static int __init probe_motherboard(void)
2408 struct macio_chip *macio = &macio_chips[0]; 2408 struct macio_chip *macio = &macio_chips[0];
2409 const char *model = NULL; 2409 const char *model = NULL;
2410 struct device_node *dt; 2410 struct device_node *dt;
2411 int ret = 0;
2411 2412
2412 /* Lookup known motherboard type in device-tree. First try an 2413 /* Lookup known motherboard type in device-tree. First try an
2413 * exact match on the "model" property, then try a "compatible" 2414 * exact match on the "model" property, then try a "compatible"
2414 * match is none is found. 2415 * match is none is found.
2415 */ 2416 */
2416 dt = find_devices("device-tree"); 2417 dt = of_find_node_by_name(NULL, "device-tree");
2417 if (dt != NULL) 2418 if (dt != NULL)
2418 model = of_get_property(dt, "model", NULL); 2419 model = of_get_property(dt, "model", NULL);
2419 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2420 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
@@ -2478,15 +2479,18 @@ static int __init probe_motherboard(void)
2478 break; 2479 break;
2479#endif /* CONFIG_POWER4 */ 2480#endif /* CONFIG_POWER4 */
2480 default: 2481 default:
2481 return -ENODEV; 2482 ret = -ENODEV;
2483 goto done;
2482 } 2484 }
2483found: 2485found:
2484#ifndef CONFIG_POWER4 2486#ifndef CONFIG_POWER4
2485 /* Fixup Hooper vs. Comet */ 2487 /* Fixup Hooper vs. Comet */
2486 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) { 2488 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
2487 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4); 2489 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
2488 if (!mach_id_ptr) 2490 if (!mach_id_ptr) {
2489 return -ENODEV; 2491 ret = -ENODEV;
2492 goto done;
2493 }
2490 /* Here, I used to disable the media-bay on comet. It 2494 /* Here, I used to disable the media-bay on comet. It
2491 * appears this is wrong, the floppy connector is actually 2495 * appears this is wrong, the floppy connector is actually
2492 * a kind of media-bay and works with the current driver. 2496 * a kind of media-bay and works with the current driver.
@@ -2544,7 +2548,9 @@ found:
2544 2548
2545 2549
2546 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name); 2550 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
2547 return 0; 2551done:
2552 of_node_put(dt);
2553 return ret;
2548} 2554}
2549 2555
2550/* Initialize the Core99 UniNorth host bridge and memory controller 2556/* Initialize the Core99 UniNorth host bridge and memory controller
@@ -2747,12 +2753,14 @@ set_initial_features(void)
2747 * differenciate them all and since that hack was there for a long 2753 * differenciate them all and since that hack was there for a long
2748 * time, I'll keep it around 2754 * time, I'll keep it around
2749 */ 2755 */
2750 if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) { 2756 if (macio_chips[0].type == macio_ohare) {
2751 struct macio_chip *macio = &macio_chips[0];
2752 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
2753 } else if (macio_chips[0].type == macio_ohare) {
2754 struct macio_chip *macio = &macio_chips[0]; 2757 struct macio_chip *macio = &macio_chips[0];
2755 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); 2758 np = of_find_node_by_name(NULL, "via-pmu");
2759 if (np)
2760 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2761 else
2762 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
2763 of_node_put(np);
2756 } else if (macio_chips[1].type == macio_ohare) { 2764 } else if (macio_chips[1].type == macio_ohare) {
2757 struct macio_chip *macio = &macio_chips[1]; 2765 struct macio_chip *macio = &macio_chips[1];
2758 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); 2766 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
@@ -2845,14 +2853,13 @@ set_initial_features(void)
2845 } 2853 }
2846 2854
2847 /* Switch airport off */ 2855 /* Switch airport off */
2848 np = find_devices("radio"); 2856 for_each_node_by_name(np, "radio") {
2849 while(np) {
2850 if (np && np->parent == macio_chips[0].of_node) { 2857 if (np && np->parent == macio_chips[0].of_node) {
2851 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON; 2858 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;
2852 core99_airport_enable(np, 0, 0); 2859 core99_airport_enable(np, 0, 0);
2853 } 2860 }
2854 np = np->next;
2855 } 2861 }
2862 of_node_put(np);
2856 } 2863 }
2857 2864
2858 /* On all machines that support sound PM, switch sound off */ 2865 /* On all machines that support sound PM, switch sound off */
@@ -2872,16 +2879,12 @@ set_initial_features(void)
2872#endif /* CONFIG_POWER4 */ 2879#endif /* CONFIG_POWER4 */
2873 2880
2874 /* On all machines, switch modem & serial ports off */ 2881 /* On all machines, switch modem & serial ports off */
2875 np = find_devices("ch-a"); 2882 for_each_node_by_name(np, "ch-a")
2876 while(np) {
2877 initial_serial_shutdown(np); 2883 initial_serial_shutdown(np);
2878 np = np->next; 2884 of_node_put(np);
2879 } 2885 for_each_node_by_name(np, "ch-b")
2880 np = find_devices("ch-b");
2881 while(np) {
2882 initial_serial_shutdown(np); 2886 initial_serial_shutdown(np);
2883 np = np->next; 2887 of_node_put(np);
2884 }
2885} 2888}
2886 2889
2887void __init 2890void __init
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 092cef4160a1..22c4ae4c6934 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -622,13 +622,14 @@ static void __init init_p2pbridge(void)
622 622
623 /* XXX it would be better here to identify the specific 623 /* XXX it would be better here to identify the specific
624 PCI-PCI bridge chip we have. */ 624 PCI-PCI bridge chip we have. */
625 if ((p2pbridge = find_devices("pci-bridge")) == 0 625 p2pbridge = of_find_node_by_name(NULL, "pci-bridge");
626 if (p2pbridge == NULL
626 || p2pbridge->parent == NULL 627 || p2pbridge->parent == NULL
627 || strcmp(p2pbridge->parent->name, "pci") != 0) 628 || strcmp(p2pbridge->parent->name, "pci") != 0)
628 return; 629 goto done;
629 if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) { 630 if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) {
630 DBG("Can't find PCI infos for PCI<->PCI bridge\n"); 631 DBG("Can't find PCI infos for PCI<->PCI bridge\n");
631 return; 632 goto done;
632 } 633 }
633 /* Warning: At this point, we have not yet renumbered all busses. 634 /* Warning: At this point, we have not yet renumbered all busses.
634 * So we must use OF walking to find out hose 635 * So we must use OF walking to find out hose
@@ -636,16 +637,18 @@ static void __init init_p2pbridge(void)
636 hose = pci_find_hose_for_OF_device(p2pbridge); 637 hose = pci_find_hose_for_OF_device(p2pbridge);
637 if (!hose) { 638 if (!hose) {
638 DBG("Can't find hose for PCI<->PCI bridge\n"); 639 DBG("Can't find hose for PCI<->PCI bridge\n");
639 return; 640 goto done;
640 } 641 }
641 if (early_read_config_word(hose, bus, devfn, 642 if (early_read_config_word(hose, bus, devfn,
642 PCI_BRIDGE_CONTROL, &val) < 0) { 643 PCI_BRIDGE_CONTROL, &val) < 0) {
643 printk(KERN_ERR "init_p2pbridge: couldn't read bridge" 644 printk(KERN_ERR "init_p2pbridge: couldn't read bridge"
644 " control\n"); 645 " control\n");
645 return; 646 goto done;
646 } 647 }
647 val &= ~PCI_BRIDGE_CTL_MASTER_ABORT; 648 val &= ~PCI_BRIDGE_CTL_MASTER_ABORT;
648 early_write_config_word(hose, bus, devfn, PCI_BRIDGE_CONTROL, val); 649 early_write_config_word(hose, bus, devfn, PCI_BRIDGE_CONTROL, val);
650done:
651 of_node_put(p2pbridge);
649} 652}
650 653
651static void __init init_second_ohare(void) 654static void __init init_second_ohare(void)
@@ -1199,8 +1202,7 @@ void __init pmac_pcibios_after_init(void)
1199 } 1202 }
1200#endif /* CONFIG_BLK_DEV_IDE */ 1203#endif /* CONFIG_BLK_DEV_IDE */
1201 1204
1202 nd = find_devices("firewire"); 1205 for_each_node_by_name(nd, "firewire") {
1203 while (nd) {
1204 if (nd->parent && (device_is_compatible(nd, "pci106b,18") || 1206 if (nd->parent && (device_is_compatible(nd, "pci106b,18") ||
1205 device_is_compatible(nd, "pci106b,30") || 1207 device_is_compatible(nd, "pci106b,30") ||
1206 device_is_compatible(nd, "pci11c1,5811")) 1208 device_is_compatible(nd, "pci11c1,5811"))
@@ -1208,15 +1210,14 @@ void __init pmac_pcibios_after_init(void)
1208 pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0); 1210 pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0);
1209 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0); 1211 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0);
1210 } 1212 }
1211 nd = nd->next;
1212 } 1213 }
1213 nd = find_devices("ethernet"); 1214 of_node_put(nd);
1214 while (nd) { 1215 for_each_node_by_name(nd, "ethernet") {
1215 if (nd->parent && device_is_compatible(nd, "gmac") 1216 if (nd->parent && device_is_compatible(nd, "gmac")
1216 && device_is_compatible(nd->parent, "uni-north")) 1217 && device_is_compatible(nd->parent, "uni-north"))
1217 pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0); 1218 pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0);
1218 nd = nd->next;
1219 } 1219 }
1220 of_node_put(nd);
1220} 1221}
1221 1222
1222#ifdef CONFIG_PPC32 1223#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index ae37d3e23783..0444e07e8d7a 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -193,8 +193,11 @@ static void pmac_show_cpuinfo(struct seq_file *m)
193#ifndef CONFIG_ADB_CUDA 193#ifndef CONFIG_ADB_CUDA
194int find_via_cuda(void) 194int find_via_cuda(void)
195{ 195{
196 if (!find_devices("via-cuda")) 196 struct device_node *dn = of_find_node_by_name(NULL, "via-cuda");
197
198 if (!dn)
197 return 0; 199 return 0;
200 of_node_put(dn);
198 printk("WARNING ! Your machine is CUDA-based but your kernel\n"); 201 printk("WARNING ! Your machine is CUDA-based but your kernel\n");
199 printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n"); 202 printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n");
200 return 0; 203 return 0;
@@ -204,8 +207,11 @@ int find_via_cuda(void)
204#ifndef CONFIG_ADB_PMU 207#ifndef CONFIG_ADB_PMU
205int find_via_pmu(void) 208int find_via_pmu(void)
206{ 209{
207 if (!find_devices("via-pmu")) 210 struct device_node *dn = of_find_node_by_name(NULL, "via-pmu");
211
212 if (!dn)
208 return 0; 213 return 0;
214 of_node_put(dn);
209 printk("WARNING ! Your machine is PMU-based but your kernel\n"); 215 printk("WARNING ! Your machine is PMU-based but your kernel\n");
210 printk(" wasn't compiled with CONFIG_ADB_PMU option !\n"); 216 printk(" wasn't compiled with CONFIG_ADB_PMU option !\n");
211 return 0; 217 return 0;
@@ -225,6 +231,8 @@ static volatile u32 *sysctrl_regs;
225 231
226static void __init ohare_init(void) 232static void __init ohare_init(void)
227{ 233{
234 struct device_node *dn;
235
228 /* this area has the CPU identification register 236 /* this area has the CPU identification register
229 and some registers used by smp boards */ 237 and some registers used by smp boards */
230 sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000); 238 sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
@@ -234,7 +242,9 @@ static void __init ohare_init(void)
234 * We assume that we have a PSX memory controller iff 242 * We assume that we have a PSX memory controller iff
235 * we have an ohare I/O controller. 243 * we have an ohare I/O controller.
236 */ 244 */
237 if (find_devices("ohare") != NULL) { 245 dn = of_find_node_by_name(NULL, "ohare");
246 if (dn) {
247 of_node_put(dn);
238 if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) { 248 if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
239 if (sysctrl_regs[4] & 0x10) 249 if (sysctrl_regs[4] & 0x10)
240 sysctrl_regs[4] |= 0x04000020; 250 sysctrl_regs[4] |= 0x04000020;
@@ -343,8 +353,15 @@ static void __init pmac_setup_arch(void)
343 353
344#ifdef CONFIG_SMP 354#ifdef CONFIG_SMP
345 /* Check for Core99 */ 355 /* Check for Core99 */
346 if (find_devices("uni-n") || find_devices("u3") || find_devices("u4")) 356 ic = of_find_node_by_name(NULL, "uni-n");
357 if (!ic)
358 ic = of_find_node_by_name(NULL, "u3");
359 if (!ic)
360 ic = of_find_node_by_name(NULL, "u4");
361 if (ic) {
362 of_node_put(ic);
347 smp_ops = &core99_smp_ops; 363 smp_ops = &core99_smp_ops;
364 }
348#ifdef CONFIG_PPC32 365#ifdef CONFIG_PPC32
349 else 366 else
350 smp_ops = &psurge_smp_ops; 367 smp_ops = &psurge_smp_ops;
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 20f328678fd1..6f32c4eca6e5 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -264,6 +264,7 @@ static void __init psurge_quad_init(void)
264static int __init smp_psurge_probe(void) 264static int __init smp_psurge_probe(void)
265{ 265{
266 int i, ncpus; 266 int i, ncpus;
267 struct device_node *dn;
267 268
268 /* We don't do SMP on the PPC601 -- paulus */ 269 /* We don't do SMP on the PPC601 -- paulus */
269 if (PVR_VER(mfspr(SPRN_PVR)) == 1) 270 if (PVR_VER(mfspr(SPRN_PVR)) == 1)
@@ -279,8 +280,10 @@ static int __init smp_psurge_probe(void)
279 * in the hammerhead memory controller in the case of the 280 * in the hammerhead memory controller in the case of the
280 * dual-cpu powersurge board. -- paulus. 281 * dual-cpu powersurge board. -- paulus.
281 */ 282 */
282 if (find_devices("hammerhead") == NULL) 283 dn = of_find_node_by_name(NULL, "hammerhead");
284 if (dn == NULL)
283 return 1; 285 return 1;
286 of_node_put(dn);
284 287
285 hhead_base = ioremap(HAMMERHEAD_BASE, 0x800); 288 hhead_base = ioremap(HAMMERHEAD_BASE, 0x800);
286 quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024); 289 quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024);
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index cdd5a0f72e3c..e54c4d9f6365 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -145,11 +145,12 @@ anslcd_init(void)
145 int retval; 145 int retval;
146 struct device_node* node; 146 struct device_node* node;
147 147
148 node = find_devices("lcd"); 148 node = of_find_node_by_name(NULL, "lcd");
149 if (!node || !node->parent) 149 if (!node || !node->parent || strcmp(node->parent->name, "gc")) {
150 return -ENODEV; 150 of_node_put(node);
151 if (strcmp(node->parent->name, "gc"))
152 return -ENODEV; 151 return -ENODEV;
152 }
153 of_node_put(node);
153 154
154 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20); 155 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
155 156
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 7b7db5db50dc..e31cb1e7a47b 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -487,7 +487,8 @@ static int __init via_pmu_dev_init(void)
487 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; 487 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART;
488 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 488 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
489 } else { 489 } else {
490 struct device_node* prim = find_devices("power-mgt"); 490 struct device_node* prim =
491 of_find_node_by_name(NULL, "power-mgt");
491 const u32 *prim_info = NULL; 492 const u32 *prim_info = NULL;
492 if (prim) 493 if (prim)
493 prim_info = of_get_property(prim, "prim-info", NULL); 494 prim_info = of_get_property(prim, "prim-info", NULL);
@@ -498,6 +499,7 @@ static int __init via_pmu_dev_init(void)
498 if (pmu_battery_count > 1) 499 if (pmu_battery_count > 1)
499 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 500 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
500 } 501 }
502 of_node_put(prim);
501 } 503 }
502#endif /* CONFIG_PPC32 */ 504#endif /* CONFIG_PPC32 */
503 505
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 86d2884e16c6..e6e61df0d071 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -2160,7 +2160,7 @@ static int find_planb(void)
2160 if (!machine_is(powermac)) 2160 if (!machine_is(powermac))
2161 return 0; 2161 return 0;
2162 2162
2163 planb_devices = find_devices("planb"); 2163 planb_devices = of_find_node_by_name(NULL, "planb");
2164 if (planb_devices == 0) { 2164 if (planb_devices == 0) {
2165 planb_num=0; 2165 planb_num=0;
2166 printk(KERN_WARNING "PlanB: no device found!\n"); 2166 printk(KERN_WARNING "PlanB: no device found!\n");
@@ -2175,12 +2175,14 @@ static int find_planb(void)
2175 if (planb_devices->n_addrs != 1) { 2175 if (planb_devices->n_addrs != 1) {
2176 printk (KERN_WARNING "PlanB: expecting 1 address for planb " 2176 printk (KERN_WARNING "PlanB: expecting 1 address for planb "
2177 "(got %d)", planb_devices->n_addrs); 2177 "(got %d)", planb_devices->n_addrs);
2178 of_node_put(planb_devices);
2178 return 0; 2179 return 0;
2179 } 2180 }
2180 2181
2181 if (planb_devices->n_intrs == 0) { 2182 if (planb_devices->n_intrs == 0) {
2182 printk(KERN_WARNING "PlanB: no intrs for device %s\n", 2183 printk(KERN_WARNING "PlanB: no intrs for device %s\n",
2183 planb_devices->full_name); 2184 planb_devices->full_name);
2185 of_node_put(planb_devices);
2184 return 0; 2186 return 0;
2185 } else { 2187 } else {
2186 irq = planb_devices->intrs[0].line; 2188 irq = planb_devices->intrs[0].line;
@@ -2202,6 +2204,7 @@ static int find_planb(void)
2202 confreg = planb_devices->addrs[0].space & 0xff; 2204 confreg = planb_devices->addrs[0].space & 0xff;
2203 old_base = planb_devices->addrs[0].address; 2205 old_base = planb_devices->addrs[0].address;
2204 new_base = 0xf1000000; 2206 new_base = 0xf1000000;
2207 of_node_put(planb_devices);
2205 2208
2206 DEBUG("PlanB: Found on bus %d, dev %d, func %d, " 2209 DEBUG("PlanB: Found on bus %d, dev %d, func %d, "
2207 "membase 0x%x (base reg. 0x%x)\n", 2210 "membase 0x%x (base reg. 0x%x)\n",
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 2b163c532e0d..cd92a3966b0c 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1467,7 +1467,8 @@ no_dma:
1467 if (ZS_IS_IRDA(uap)) 1467 if (ZS_IS_IRDA(uap))
1468 uap->port_type = PMAC_SCC_IRDA; 1468 uap->port_type = PMAC_SCC_IRDA;
1469 if (ZS_IS_INTMODEM(uap)) { 1469 if (ZS_IS_INTMODEM(uap)) {
1470 struct device_node* i2c_modem = find_devices("i2c-modem"); 1470 struct device_node* i2c_modem =
1471 of_find_node_by_name(NULL, "i2c-modem");
1471 if (i2c_modem) { 1472 if (i2c_modem) {
1472 const char* mid = 1473 const char* mid =
1473 of_get_property(i2c_modem, "modem-id", NULL); 1474 of_get_property(i2c_modem, "modem-id", NULL);
@@ -1482,6 +1483,7 @@ no_dma:
1482 } 1483 }
1483 printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n", 1484 printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n",
1484 mid ? (*mid) : 0); 1485 mid ? (*mid) : 0);
1486 of_node_put(i2c_modem);
1485 } else { 1487 } else {
1486 printk(KERN_INFO "pmac_zilog: serial modem detected\n"); 1488 printk(KERN_INFO "pmac_zilog: serial modem detected\n");
1487 } 1489 }
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index fd60dba294da..8b762739b1e0 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -179,12 +179,14 @@ MODULE_LICENSE("GPL");
179int init_module(void) 179int init_module(void)
180{ 180{
181 struct device_node *dp; 181 struct device_node *dp;
182 int ret = -ENXIO;
182 183
183 dp = find_devices("control"); 184 dp = of_find_node_by_name(NULL, "control");
184 if (dp != 0 && !control_of_init(dp)) 185 if (dp != 0 && !control_of_init(dp))
185 return 0; 186 ret = 0;
187 of_node_put(dp);
186 188
187 return -ENXIO; 189 return ret;
188} 190}
189 191
190void cleanup_module(void) 192void cleanup_module(void)
@@ -589,16 +591,18 @@ static int __init control_init(void)
589{ 591{
590 struct device_node *dp; 592 struct device_node *dp;
591 char *option = NULL; 593 char *option = NULL;
594 int ret = -ENXIO;
592 595
593 if (fb_get_options("controlfb", &option)) 596 if (fb_get_options("controlfb", &option))
594 return -ENODEV; 597 return -ENODEV;
595 control_setup(option); 598 control_setup(option);
596 599
597 dp = find_devices("control"); 600 dp = of_find_node_by_name(NULL, "control");
598 if (dp != 0 && !control_of_init(dp)) 601 if (dp != 0 && !control_of_init(dp))
599 return 0; 602 ret = 0;
603 of_node_put(dp);
600 604
601 return -ENXIO; 605 return ret;
602} 606}
603 607
604module_init(control_init); 608module_init(control_init);
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 990489cac9b9..ec400f608e16 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -112,9 +112,6 @@ static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_e
112} 112}
113 113
114 114
115/* OBSOLETE: Old style node lookup */
116extern struct device_node *find_devices(const char *name);
117
118/* New style node lookup */ 115/* New style node lookup */
119extern struct device_node *of_find_node_by_name(struct device_node *from, 116extern struct device_node *of_find_node_by_name(struct device_node *from,
120 const char *name); 117 const char *name);
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 977b91cea603..730fa1d001a5 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -346,14 +346,16 @@ int gpio_headphone_irq;
346int 346int
347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol) 347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol)
348{ 348{
349 struct device_node *gpiop;
349 struct device_node *np; 350 struct device_node *np;
350 const u32* pp; 351 const u32* pp;
352 int ret = -ENODEV;
351 353
352 np = find_devices("gpio"); 354 gpiop = of_find_node_by_name(NULL, "gpio");
353 if (!np) 355 if (!gpiop)
354 return -ENODEV; 356 goto done;
355 357
356 np = np->child; 358 np = of_get_next_child(gpiop, NULL);
357 while(np != 0) { 359 while(np != 0) {
358 if (name) { 360 if (name) {
359 const char *property = 361 const char *property =
@@ -362,20 +364,24 @@ setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int*
362 break; 364 break;
363 } else if (compatible && device_is_compatible(np, compatible)) 365 } else if (compatible && device_is_compatible(np, compatible))
364 break; 366 break;
365 np = np->sibling; 367 np = of_get_next_child(gpiop, np);
366 } 368 }
367 if (!np) 369 if (!np)
368 return -ENODEV; 370 goto done;
369 pp = of_get_property(np, "AAPL,address", NULL); 371 pp = of_get_property(np, "AAPL,address", NULL);
370 if (!pp) 372 if (!pp)
371 return -ENODEV; 373 goto done;
372 *gpio_addr = (*pp) & 0x0000ffff; 374 *gpio_addr = (*pp) & 0x0000ffff;
373 pp = of_get_property(np, "audio-gpio-active-state", NULL); 375 pp = of_get_property(np, "audio-gpio-active-state", NULL);
374 if (pp) 376 if (pp)
375 *gpio_pol = *pp; 377 *gpio_pol = *pp;
376 else 378 else
377 *gpio_pol = 1; 379 *gpio_pol = 1;
378 return irq_of_parse_and_map(np, 0); 380 ret = irq_of_parse_and_map(np, 0);
381done:
382 of_node_put(np);
383 of_node_put(gpiop);
384 return ret;
379} 385}
380 386
381static inline void 387static inline void
@@ -2552,32 +2558,33 @@ set_model(void)
2552static struct device_node* __init 2558static struct device_node* __init
2553get_snd_io_node(void) 2559get_snd_io_node(void)
2554{ 2560{
2555 struct device_node *np = NULL; 2561 struct device_node *np;
2556 2562
2557 /* set up awacs_node for early OF which doesn't have a full set of 2563 /* set up awacs_node for early OF which doesn't have a full set of
2558 * properties on davbus 2564 * properties on davbus
2559 */ 2565 */
2560 2566 awacs_node = of_find_node_by_name(NULL, "awacs");
2561 awacs_node = find_devices("awacs");
2562 if (awacs_node) 2567 if (awacs_node)
2563 awacs_revision = AWACS_AWACS; 2568 awacs_revision = AWACS_AWACS;
2564 2569
2565 /* powermac models after 9500 (other than those which use DACA or 2570 /* powermac models after 9500 (other than those which use DACA or
2566 * Tumbler) have a node called "davbus". 2571 * Tumbler) have a node called "davbus".
2567 */ 2572 */
2568 np = find_devices("davbus"); 2573 np = of_find_node_by_name(NULL, "davbus");
2569 /* 2574 /*
2570 * if we didn't find a davbus device, try 'i2s-a' since 2575 * if we didn't find a davbus device, try 'i2s-a' since
2571 * this seems to be what iBooks (& Tumbler) have. 2576 * this seems to be what iBooks (& Tumbler) have.
2572 */ 2577 */
2573 if (np == NULL) 2578 if (np == NULL) {
2574 np = i2s_node = find_devices("i2s-a"); 2579 i2s_node = of_find_node_by_name(NULL, "i2s-a");
2580 np = of_node_get(i2s_node);
2581 }
2575 2582
2576 /* if we didn't find this - perhaps we are on an early model 2583 /* if we didn't find this - perhaps we are on an early model
2577 * which _only_ has an 'awacs' node 2584 * which _only_ has an 'awacs' node
2578 */ 2585 */
2579 if (np == NULL && awacs_node) 2586 if (np == NULL && awacs_node)
2580 np = awacs_node ; 2587 np = of_node_get(awacs_node);
2581 2588
2582 /* if we failed all these return null - this will cause the 2589 /* if we failed all these return null - this will cause the
2583 * driver to give up... 2590 * driver to give up...
@@ -2596,9 +2603,9 @@ get_snd_info_node(struct device_node *io)
2596{ 2603{
2597 struct device_node *info; 2604 struct device_node *info;
2598 2605
2599 info = find_devices("sound"); 2606 for_each_node_by_name(info, "sound")
2600 while (info && info->parent != io) 2607 if (info->parent == io)
2601 info = info->next; 2608 break;
2602 return info; 2609 return info;
2603} 2610}
2604 2611
@@ -2634,11 +2641,17 @@ get_codec_type(struct device_node *info)
2634static void __init 2641static void __init
2635get_expansion_type(void) 2642get_expansion_type(void)
2636{ 2643{
2637 if (find_devices("perch") != NULL) 2644 struct device_node *dn;
2645
2646 dn = of_find_node_by_name(NULL, "perch");
2647 if (dn != NULL)
2638 has_perch = 1; 2648 has_perch = 1;
2649 of_node_put(dn);
2639 2650
2640 if (find_devices("pb-ziva-pc") != NULL) 2651 dn = of_find_node_by_name(NULL, "pb-ziva-pc");
2652 if (dn != NULL)
2641 has_ziva = 1; 2653 has_ziva = 1;
2654 of_node_put(dn);
2642 /* need to work out how we deal with iMac SRS module */ 2655 /* need to work out how we deal with iMac SRS module */
2643} 2656}
2644 2657
@@ -2827,7 +2840,7 @@ int __init dmasound_awacs_init(void)
2827#ifdef DEBUG_DMASOUND 2840#ifdef DEBUG_DMASOUND
2828printk("dmasound_pmac: couldn't find sound io OF node\n"); 2841printk("dmasound_pmac: couldn't find sound io OF node\n");
2829#endif 2842#endif
2830 return -ENODEV ; 2843 goto no_device;
2831 } 2844 }
2832 2845
2833 /* find the OF node that tells us about the sound sub-system 2846 /* find the OF node that tells us about the sound sub-system
@@ -2839,7 +2852,7 @@ printk("dmasound_pmac: couldn't find sound io OF node\n");
2839#ifdef DEBUG_DMASOUND 2852#ifdef DEBUG_DMASOUND
2840printk("dmasound_pmac: couldn't find 'sound' OF node\n"); 2853printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2841#endif 2854#endif
2842 return -ENODEV ; 2855 goto no_device;
2843 } 2856 }
2844 } 2857 }
2845 2858
@@ -2848,7 +2861,7 @@ printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2848#ifdef DEBUG_DMASOUND 2861#ifdef DEBUG_DMASOUND
2849printk("dmasound_pmac: couldn't find a Codec we can handle\n"); 2862printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2850#endif 2863#endif
2851 return -ENODEV ; /* we don't know this type of h/w */ 2864 goto no_device; /* we don't know this type of h/w */
2852 } 2865 }
2853 2866
2854 /* set up perch, ziva, SRS or whatever else we have as sound 2867 /* set up perch, ziva, SRS or whatever else we have as sound
@@ -2866,11 +2879,12 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2866 * machines). 2879 * machines).
2867 */ 2880 */
2868 if (awacs_node) { 2881 if (awacs_node) {
2869 io = awacs_node ; 2882 of_node_put(io);
2883 io = of_node_get(awacs_node);
2870 if (of_get_address(io, 2, NULL, NULL) == NULL) { 2884 if (of_get_address(io, 2, NULL, NULL) == NULL) {
2871 printk("dmasound_pmac: can't use %s\n", 2885 printk("dmasound_pmac: can't use %s\n",
2872 io->full_name); 2886 io->full_name);
2873 return -ENODEV; 2887 goto no_device;
2874 } 2888 }
2875 } else 2889 } else
2876 printk("dmasound_pmac: can't use %s\n", io->full_name); 2890 printk("dmasound_pmac: can't use %s\n", io->full_name);
@@ -2881,7 +2895,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2881 awacs_rsrc[0].end - awacs_rsrc[0].start + 1, 2895 awacs_rsrc[0].end - awacs_rsrc[0].start + 1,
2882 " (IO)") == NULL) { 2896 " (IO)") == NULL) {
2883 printk(KERN_ERR "dmasound: can't request IO resource !\n"); 2897 printk(KERN_ERR "dmasound: can't request IO resource !\n");
2884 return -ENODEV; 2898 goto no_device;
2885 } 2899 }
2886 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) || 2900 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) ||
2887 request_mem_region(awacs_rsrc[1].start, 2901 request_mem_region(awacs_rsrc[1].start,
@@ -2890,7 +2904,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2890 release_mem_region(awacs_rsrc[0].start, 2904 release_mem_region(awacs_rsrc[0].start,
2891 awacs_rsrc[0].end - awacs_rsrc[0].start + 1); 2905 awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
2892 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n"); 2906 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n");
2893 return -ENODEV; 2907 goto no_device;
2894 } 2908 }
2895 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) || 2909 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) ||
2896 request_mem_region(awacs_rsrc[2].start, 2910 request_mem_region(awacs_rsrc[2].start,
@@ -2901,7 +2915,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2901 release_mem_region(awacs_rsrc[1].start, 2915 release_mem_region(awacs_rsrc[1].start,
2902 awacs_rsrc[1].end - awacs_rsrc[1].start + 1); 2916 awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
2903 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n"); 2917 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n");
2904 return -ENODEV; 2918 goto no_device;
2905 } 2919 }
2906 2920
2907 awacs_beep_dev = input_allocate_device(); 2921 awacs_beep_dev = input_allocate_device();
@@ -2913,7 +2927,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2913 release_mem_region(awacs_rsrc[2].start, 2927 release_mem_region(awacs_rsrc[2].start,
2914 awacs_rsrc[2].end - awacs_rsrc[2].start + 1); 2928 awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
2915 printk(KERN_ERR "dmasound: can't allocate input device !\n"); 2929 printk(KERN_ERR "dmasound: can't allocate input device !\n");
2916 return -ENOMEM; 2930 goto no_device;
2917 } 2931 }
2918 2932
2919 awacs_beep_dev->name = "dmasound beeper"; 2933 awacs_beep_dev->name = "dmasound beeper";
@@ -2941,7 +2955,8 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2941 awacs_rx_irq = irq_of_parse_and_map(io, 2); 2955 awacs_rx_irq = irq_of_parse_and_map(io, 2);
2942 2956
2943 /* Hack for legacy crap that will be killed someday */ 2957 /* Hack for legacy crap that will be killed someday */
2944 awacs_node = io; 2958 of_node_put(awacs_node);
2959 awacs_node = of_node_get(io);
2945 2960
2946 /* if we have an awacs or screamer - probe the chip to make 2961 /* if we have an awacs or screamer - probe the chip to make
2947 * sure we have the right revision. 2962 * sure we have the right revision.
@@ -2990,6 +3005,8 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
2990 3005
2991 /* if it's there use it to set up frame rates */ 3006 /* if it's there use it to set up frame rates */
2992 init_frame_rates(prop, l) ; 3007 init_frame_rates(prop, l) ;
3008 of_node_put(info);
3009 info = NULL;
2993 } 3010 }
2994 3011
2995 if (awacs) 3012 if (awacs)
@@ -3159,7 +3176,16 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
3159 */ 3176 */
3160 input_register_device(awacs_beep_dev); 3177 input_register_device(awacs_beep_dev);
3161 3178
3179 of_node_put(io);
3180
3162 return dmasound_init(); 3181 return dmasound_init();
3182
3183no_device:
3184 of_node_put(info);
3185 of_node_put(awacs_node);
3186 of_node_put(i2s_node);
3187 of_node_put(io);
3188 return -ENODEV ;
3163} 3189}
3164 3190
3165static void __exit dmasound_awacs_cleanup(void) 3191static void __exit dmasound_awacs_cleanup(void)
@@ -3178,6 +3204,8 @@ static void __exit dmasound_awacs_cleanup(void)
3178 } 3204 }
3179 dmasound_deinit(); 3205 dmasound_deinit();
3180 3206
3207 of_node_put(awacs_node);
3208 of_node_put(i2s_node);
3181} 3209}
3182 3210
3183MODULE_DESCRIPTION("PowerMac built-in audio driver."); 3211MODULE_DESCRIPTION("PowerMac built-in audio driver.");
diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c
index 11257600d6d0..b295ef682192 100644
--- a/sound/oss/dmasound/tas_common.c
+++ b/sound/oss/dmasound/tas_common.c
@@ -41,7 +41,6 @@
41 41
42static u8 tas_i2c_address = 0x34; 42static u8 tas_i2c_address = 0x34;
43static struct i2c_client *tas_client; 43static struct i2c_client *tas_client;
44static struct device_node* tas_node;
45 44
46static int tas_attach_adapter(struct i2c_adapter *); 45static int tas_attach_adapter(struct i2c_adapter *);
47static int tas_detach_client(struct i2c_client *); 46static int tas_detach_client(struct i2c_client *);
@@ -191,13 +190,14 @@ int __init
191tas_init(int driver_id, const char *driver_name) 190tas_init(int driver_id, const char *driver_name)
192{ 191{
193 const u32* paddr; 192 const u32* paddr;
193 struct device_node *tas_node;
194 194
195 printk(KERN_INFO "tas driver [%s])\n", driver_name); 195 printk(KERN_INFO "tas driver [%s])\n", driver_name);
196 196
197#ifndef CONFIG_I2C_POWERMAC 197#ifndef CONFIG_I2C_POWERMAC
198 request_module("i2c-powermac"); 198 request_module("i2c-powermac");
199#endif 199#endif
200 tas_node = find_devices("deq"); 200 tas_node = of_find_node_by_name("deq");
201 if (tas_node == NULL) 201 if (tas_node == NULL)
202 return -ENODEV; 202 return -ENODEV;
203 paddr = of_get_property(tas_node, "i2c-address", NULL); 203 paddr = of_get_property(tas_node, "i2c-address", NULL);
@@ -208,6 +208,7 @@ tas_init(int driver_id, const char *driver_name)
208 } else 208 } else
209 printk(KERN_INFO "using i2c address: 0x%x (default)\n", 209 printk(KERN_INFO "using i2c address: 0x%x (default)\n",
210 tas_i2c_address); 210 tas_i2c_address);
211 of_node_put(tas_node);
211 212
212 return i2c_add_driver(&tas_driver); 213 return i2c_add_driver(&tas_driver);
213} 214}
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 5e829683d1ad..2bae9c1a2b54 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -816,6 +816,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
816 816
817 if (chip->pdev) 817 if (chip->pdev)
818 pci_dev_put(chip->pdev); 818 pci_dev_put(chip->pdev);
819 of_node_put(chip->node);
819 kfree(chip); 820 kfree(chip);
820 return 0; 821 return 0;
821} 822}
@@ -863,7 +864,8 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
863 */ 864 */
864static int __init snd_pmac_detect(struct snd_pmac *chip) 865static int __init snd_pmac_detect(struct snd_pmac *chip)
865{ 866{
866 struct device_node *sound = NULL; 867 struct device_node *sound;
868 struct device_node *dn;
867 const unsigned int *prop; 869 const unsigned int *prop;
868 unsigned int l; 870 unsigned int l;
869 struct macio_chip* macio; 871 struct macio_chip* macio;
@@ -891,22 +893,21 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
891 else if (machine_is_compatible("PowerBook1,1") 893 else if (machine_is_compatible("PowerBook1,1")
892 || machine_is_compatible("AAPL,PowerBook1998")) 894 || machine_is_compatible("AAPL,PowerBook1998"))
893 chip->is_pbook_G3 = 1; 895 chip->is_pbook_G3 = 1;
894 chip->node = find_devices("awacs"); 896 chip->node = of_find_node_by_name(NULL, "awacs");
895 if (chip->node) 897 sound = of_node_get(chip->node);
896 sound = chip->node;
897 898
898 /* 899 /*
899 * powermac G3 models have a node called "davbus" 900 * powermac G3 models have a node called "davbus"
900 * with a child called "sound". 901 * with a child called "sound".
901 */ 902 */
902 if (!chip->node) 903 if (!chip->node)
903 chip->node = find_devices("davbus"); 904 chip->node = of_find_node_by_name(NULL, "davbus");
904 /* 905 /*
905 * if we didn't find a davbus device, try 'i2s-a' since 906 * if we didn't find a davbus device, try 'i2s-a' since
906 * this seems to be what iBooks have 907 * this seems to be what iBooks have
907 */ 908 */
908 if (! chip->node) { 909 if (! chip->node) {
909 chip->node = find_devices("i2s-a"); 910 chip->node = of_find_node_by_name(NULL, "i2s-a");
910 if (chip->node && chip->node->parent && 911 if (chip->node && chip->node->parent &&
911 chip->node->parent->parent) { 912 chip->node->parent->parent) {
912 if (device_is_compatible(chip->node->parent->parent, 913 if (device_is_compatible(chip->node->parent->parent,
@@ -918,12 +919,14 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
918 return -ENODEV; 919 return -ENODEV;
919 920
920 if (!sound) { 921 if (!sound) {
921 sound = find_devices("sound"); 922 sound = of_find_node_by_name(NULL, "sound");
922 while (sound && sound->parent != chip->node) 923 while (sound && sound->parent != chip->node)
923 sound = sound->next; 924 sound = of_find_node_by_name(sound, "sound");
924 } 925 }
925 if (! sound) 926 if (! sound) {
927 of_node_put(chip->node);
926 return -ENODEV; 928 return -ENODEV;
929 }
927 prop = of_get_property(sound, "sub-frame", NULL); 930 prop = of_get_property(sound, "sub-frame", NULL);
928 if (prop && *prop < 16) 931 if (prop && *prop < 16)
929 chip->subframe = *prop; 932 chip->subframe = *prop;
@@ -934,6 +937,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
934 printk(KERN_INFO "snd-powermac no longer handles any " 937 printk(KERN_INFO "snd-powermac no longer handles any "
935 "machines with a layout-id property " 938 "machines with a layout-id property "
936 "in the device-tree, use snd-aoa.\n"); 939 "in the device-tree, use snd-aoa.\n");
940 of_node_put(chip->node);
937 return -ENODEV; 941 return -ENODEV;
938 } 942 }
939 /* This should be verified on older screamers */ 943 /* This should be verified on older screamers */
@@ -971,7 +975,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
971 prop = of_get_property(sound, "device-id", NULL); 975 prop = of_get_property(sound, "device-id", NULL);
972 if (prop) 976 if (prop)
973 chip->device_id = *prop; 977 chip->device_id = *prop;
974 chip->has_iic = (find_devices("perch") != NULL); 978 dn = of_find_node_by_name(NULL, "perch");
979 chip->has_iic = (dn != NULL);
980 of_node_put(dn);
975 981
976 /* We need the PCI device for DMA allocations, let's use a crude method 982 /* We need the PCI device for DMA allocations, let's use a crude method
977 * for now ... 983 * for now ...
@@ -1021,6 +1027,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
1021 chip->freqs_ok = 1; 1027 chip->freqs_ok = 1;
1022 } 1028 }
1023 1029
1030 of_node_put(sound);
1024 return 0; 1031 return 0;
1025} 1032}
1026 1033
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 8e01b558131d..54e333fbb1d0 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1031,32 +1031,40 @@ static irqreturn_t headphone_intr(int irq, void *devid)
1031/* look for audio-gpio device */ 1031/* look for audio-gpio device */
1032static struct device_node *find_audio_device(const char *name) 1032static struct device_node *find_audio_device(const char *name)
1033{ 1033{
1034 struct device_node *gpiop;
1034 struct device_node *np; 1035 struct device_node *np;
1035 1036
1036 if (! (np = find_devices("gpio"))) 1037 gpiop = of_find_node_by_name(NULL, "gpio");
1038 if (! gpiop)
1037 return NULL; 1039 return NULL;
1038 1040
1039 for (np = np->child; np; np = np->sibling) { 1041 for (np = of_get_next_child(gpiop, NULL); np;
1042 np = of_get_next_child(gpiop, np)) {
1040 const char *property = of_get_property(np, "audio-gpio", NULL); 1043 const char *property = of_get_property(np, "audio-gpio", NULL);
1041 if (property && strcmp(property, name) == 0) 1044 if (property && strcmp(property, name) == 0)
1042 return np; 1045 break;
1043 } 1046 }
1044 return NULL; 1047 of_node_put(gpiop);
1048 return np;
1045} 1049}
1046 1050
1047/* look for audio-gpio device */ 1051/* look for audio-gpio device */
1048static struct device_node *find_compatible_audio_device(const char *name) 1052static struct device_node *find_compatible_audio_device(const char *name)
1049{ 1053{
1054 struct device_node *gpiop;
1050 struct device_node *np; 1055 struct device_node *np;
1051 1056
1052 if (! (np = find_devices("gpio"))) 1057 gpiop = of_find_node_by_name(NULL, "gpio");
1058 if (!gpiop)
1053 return NULL; 1059 return NULL;
1054 1060
1055 for (np = np->child; np; np = np->sibling) { 1061 for (np = of_get_next_child(gpiop, NULL); np;
1062 np = of_get_next_child(gpiop, np)) {
1056 if (device_is_compatible(np, name)) 1063 if (device_is_compatible(np, name))
1057 return np; 1064 break;
1058 } 1065 }
1059 return NULL; 1066 of_node_put(gpiop);
1067 return np;
1060} 1068}
1061 1069
1062/* find an audio device and get its address */ 1070/* find an audio device and get its address */
@@ -1066,6 +1074,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1066 struct device_node *node; 1074 struct device_node *node;
1067 const u32 *base; 1075 const u32 *base;
1068 u32 addr; 1076 u32 addr;
1077 long ret;
1069 1078
1070 if (is_compatible) 1079 if (is_compatible)
1071 node = find_compatible_audio_device(device); 1080 node = find_compatible_audio_device(device);
@@ -1083,6 +1092,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1083 if (!base) { 1092 if (!base) {
1084 DBG("(E) cannot find address for device %s !\n", device); 1093 DBG("(E) cannot find address for device %s !\n", device);
1085 snd_printd("cannot find address for device %s\n", device); 1094 snd_printd("cannot find address for device %s\n", device);
1095 of_node_put(node);
1086 return -ENODEV; 1096 return -ENODEV;
1087 } 1097 }
1088 addr = *base; 1098 addr = *base;
@@ -1124,7 +1134,9 @@ static long tumbler_find_device(const char *device, const char *platform,
1124 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n", 1134 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n",
1125 device, gp->addr, gp->active_state); 1135 device, gp->addr, gp->active_state);
1126 1136
1127 return irq_of_parse_and_map(node, 0); 1137 ret = irq_of_parse_and_map(node, 0);
1138 of_node_put(node);
1139 return ret;
1128} 1140}
1129 1141
1130/* reset audio */ 1142/* reset audio */
@@ -1342,9 +1354,9 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1342 return err; 1354 return err;
1343 1355
1344 /* set up TAS */ 1356 /* set up TAS */
1345 tas_node = find_devices("deq"); 1357 tas_node = of_find_node_by_name(NULL, "deq");
1346 if (tas_node == NULL) 1358 if (tas_node == NULL)
1347 tas_node = find_devices("codec"); 1359 tas_node = of_find_node_by_name(NULL, "codec");
1348 if (tas_node == NULL) 1360 if (tas_node == NULL)
1349 return -ENODEV; 1361 return -ENODEV;
1350 1362
@@ -1355,6 +1367,7 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1355 mix->i2c.addr = (*paddr) >> 1; 1367 mix->i2c.addr = (*paddr) >> 1;
1356 else 1368 else
1357 mix->i2c.addr = TAS_I2C_ADDR; 1369 mix->i2c.addr = TAS_I2C_ADDR;
1370 of_node_put(tas_node);
1358 1371
1359 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr); 1372 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr);
1360 1373