Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Remove old interface find_devices

Replace uses with of_find_node_by_name and for_each_node_by_name.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Stephen Rothwell and committed by
Paul Mackerras
30686ba6 1658ab66

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