diff -Nru a/arch/ppc64/kernel/chrp_setup.c b/arch/ppc64/kernel/chrp_setup.c --- a/arch/ppc64/kernel/chrp_setup.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/chrp_setup.c Tue Sep 23 14:55:44 2003 @@ -97,16 +97,18 @@ seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq); - root = find_path_device("/"); + root = of_find_node_by_path("/"); if (root) model = get_property(root, "model", NULL); seq_printf(m, "machine\t\t: CHRP %s\n", model); + of_node_put(root); } #define I8042_DATA_REG 0x60 void __init chrp_request_regions(void) { + struct device_node *i8042; request_region(0x20,0x20,"pic1"); request_region(0xa0,0x20,"pic2"); request_region(0x00,0x20,"dma1"); @@ -119,8 +121,9 @@ * tree and reserve the region if it does not appear. Later on * the i8042 code will try and reserve this region and fail. */ - if (!find_type_devices("8042")) + if (!(i8042 = of_find_node_by_type(NULL, "8042"))) request_region(I8042_DATA_REG, 16, "reserved (no i8042)"); + of_node_put(i8042); } void __init @@ -159,7 +162,7 @@ #endif /* Find the Open PIC if present */ - root = find_path_device("/"); + root = of_find_node_by_path("/"); opprop = (unsigned int *) get_property(root, "platform-open-pic", NULL); if (opprop != 0) { @@ -171,6 +174,7 @@ printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic); OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE); } + of_node_put(root); #ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con; @@ -274,7 +278,7 @@ struct device_node * dn; char * hypertas; unsigned int len; - dn = find_path_device("/rtas"); + dn = of_find_node_by_path("/rtas"); cur_cpu_spec->firmware_features = 0; hypertas = get_property(dn, "ibm,hypertas-functions", &len); if (hypertas) { @@ -293,6 +297,7 @@ hypertas+= hypertas_len +1; } } + of_node_put(dn); udbg_printf("firmware_features bitmask: 0x%x \n", cur_cpu_spec->firmware_features); } @@ -418,7 +423,7 @@ * to tell us the rate at which the decrementer counts. */ freq = 16666000; /* hardcoded default */ - cpu = find_type_devices("cpu"); + cpu = of_find_node_by_type(NULL, "cpu"); if (cpu != 0) { fp = (int *) get_property(cpu, "timebase-frequency", NULL); if (fp != 0) @@ -432,6 +437,7 @@ processor_freq = *fp; } ppc_proc_freq = processor_freq; + of_node_put(cpu); printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", freq/1000000, freq%1000000 ); diff -Nru a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c --- a/arch/ppc64/kernel/eeh.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/eeh.c Tue Sep 23 14:55:44 2003 @@ -257,7 +257,7 @@ /* Enable EEH for all adapters. Note that eeh requires buid's */ info.adapters_enabled = 0; - for (phb = find_devices("pci"); phb; phb = phb->next) { + for (phb = of_find_node_by_name(NULL, "pci"); phb; phb = of_find_node_by_name(phb, "pci")) { int len; int *buid_vals = (int *) get_property(phb, "ibm,fw-phb-id", &len); if (!buid_vals) diff -Nru a/arch/ppc64/kernel/nvram.c b/arch/ppc64/kernel/nvram.c --- a/arch/ppc64/kernel/nvram.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/nvram.c Tue Sep 23 14:55:44 2003 @@ -116,7 +116,7 @@ { struct device_node *nvram; unsigned int *nbytes_p, proplen; - if ((nvram = find_type_devices("nvram")) != NULL) { + if ((nvram = of_find_node_by_type(NULL, "nvram")) != NULL) { nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen); if (nbytes_p && proplen == sizeof(unsigned int)) { rtas_nvram_size = *nbytes_p; @@ -125,6 +125,7 @@ nvram_fetch = rtas_token("nvram-fetch"); nvram_store = rtas_token("nvram-store"); printk(KERN_INFO "PPC64 nvram contains %d bytes\n", rtas_nvram_size); + of_node_put(nvram); return misc_register(&nvram_dev); } diff -Nru a/arch/ppc64/kernel/open_pic.c b/arch/ppc64/kernel/open_pic.c --- a/arch/ppc64/kernel/open_pic.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/open_pic.c Tue Sep 23 14:55:44 2003 @@ -152,7 +152,7 @@ struct device_node *kbd; #endif - if (!(np = find_devices("pci")) + if (!(np = of_find_node_by_name(NULL, "pci")) || !(addrp = (unsigned int *) get_property(np, "8259-interrupt-acknowledge", NULL))) printk(KERN_ERR "Cannot find pci to get ack address\n"); @@ -168,6 +168,7 @@ openpic_init(1, NUM_ISA_INTERRUPTS, chrp_int_ack_special, nmi_irq); for ( i = 0 ; i < NUM_ISA_INTERRUPTS ; i++ ) get_real_irq_desc(i)->handler = &i8259_pic; + of_node_put(np); } static inline u_int openpic_read(volatile u_int *addr) diff -Nru a/arch/ppc64/kernel/pSeries_htab.c b/arch/ppc64/kernel/pSeries_htab.c --- a/arch/ppc64/kernel/pSeries_htab.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/pSeries_htab.c Tue Sep 23 14:55:44 2003 @@ -389,10 +389,11 @@ ppc_md.hpte_remove = pSeries_hpte_remove; /* Disable TLB batching on nighthawk */ - root = find_path_device("/"); + root = of_find_node_by_path("/"); if (root) { model = get_property(root, "model", NULL); if (strcmp(model, "CHRP IBM,9076-N81")) ppc_md.flush_hash_range = pSeries_flush_hash_range; + of_node_put(root); } } diff -Nru a/arch/ppc64/kernel/pSeries_lpar.c b/arch/ppc64/kernel/pSeries_lpar.c --- a/arch/ppc64/kernel/pSeries_lpar.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/pSeries_lpar.c Tue Sep 23 14:55:44 2003 @@ -234,11 +234,12 @@ * is the starting termno (the one we use) and the second is the * number of terminals. */ - np = find_path_device("/rtas"); + np = of_find_node_by_path("/rtas"); if (np) { u32 *termno = (u32 *)get_property(np, "ibm,termno", 0); if (termno) vtermno = termno[0]; + of_node_put(np); } ppc_md.udbg_putc = udbg_putcLP; @@ -290,15 +291,17 @@ { u32 *termno; struct device_node *dn; + int ret = 0; - if ((dn = find_path_device("/rtas")) != NULL) { + if ((dn = of_find_node_by_path("/rtas")) != NULL) { if ((termno = (u32 *)get_property(dn, "ibm,termno", 0)) != NULL) { if (start_termno) *start_termno = termno[0]; - return termno[1]; + ret = termno[1]; } + of_node_put(dn); } - return 0; + return ret; } long pSeries_lpar_hpte_insert(unsigned long hpte_group, diff -Nru a/arch/ppc64/kernel/pSeries_pci.c b/arch/ppc64/kernel/pSeries_pci.c --- a/arch/ppc64/kernel/pSeries_pci.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/pSeries_pci.c Tue Sep 23 14:55:44 2003 @@ -188,6 +188,7 @@ struct resource *res; int np, na = prom_n_addr_cells(dev); unsigned long pci_addr, cpu_phys_addr; + struct device_node *isa_dn; np = na + 5; @@ -219,8 +220,11 @@ size, _PAGE_NO_CACHE); if (primary) { pci_io_base = (unsigned long)hose->io_base_virt; - if (find_type_devices("isa")) + isa_dn = of_find_node_by_type(NULL, "isa"); + if (isa_dn) { isa_io_base = pci_io_base; + of_node_put(isa_dn); + } } res = &hose->io_resource; @@ -386,7 +390,7 @@ unsigned int root_size_cells = 0; unsigned int index; unsigned int *opprop; - struct device_node *root = find_path_device("/"); + struct device_node *root = of_find_node_by_path("/"); read_pci_config = rtas_token("read-pci-config"); write_pci_config = rtas_token("write-pci-config"); @@ -402,7 +406,9 @@ index = 0; - for (node = root->child; node != NULL; node = node->sibling) { + for (node = of_get_next_child(root, NULL); + node != NULL; + node = of_get_next_child(root, node)) { if (node->type == NULL || strcmp(node->type, "pci") != 0) continue; @@ -420,6 +426,7 @@ index++; } + of_node_put(root); pci_devs_phb_init(); return 0; @@ -525,11 +532,12 @@ struct device_node *root; char *model; - root = find_path_device("/"); + root = of_find_node_by_path("/"); if (root) { model = get_property(root, "model", NULL); if (model && !strcmp(model, "IBM,7013-S7A")) s7a_workaround = 1; + of_node_put(root); } } diff -Nru a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c --- a/arch/ppc64/kernel/prom.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/prom.c Tue Sep 23 14:55:44 2003 @@ -1465,7 +1465,7 @@ klimit = mem; - rtas.dev = find_devices("rtas"); + rtas.dev = of_find_node_by_name(NULL, "rtas"); } static unsigned long __init @@ -1917,11 +1917,14 @@ machine_is_compatible(const char *compat) { struct device_node *root; + int rc = 0; - root = find_path_device("/"); - if (root == 0) - return 0; - return device_is_compatible(root, compat); + root = of_find_node_by_path("/"); + if (root) { + rc = device_is_compatible(root, compat); + of_node_put(root); + } + return rc; } /* diff -Nru a/arch/ppc64/kernel/ras.c b/arch/ppc64/kernel/ras.c --- a/arch/ppc64/kernel/ras.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/ras.c Tue Sep 23 14:55:44 2003 @@ -69,7 +69,7 @@ struct device_node *np; unsigned int *ireg, len, i; - if((np = find_path_device("/event-sources/internal-errors")) && + if((np = of_find_node_by_path("/event-sources/internal-errors")) && (ireg = (unsigned int *)get_property(np, "open-pic-interrupt", &len))) { for(i=0; i<(len / sizeof(*ireg)); i++) { @@ -79,8 +79,9 @@ ireg++; } } + of_node_put(np); - if((np = find_path_device("/event-sources/epow-events")) && + if((np = of_find_node_by_path("/event-sources/epow-events")) && (ireg = (unsigned int *)get_property(np, "open-pic-interrupt", &len))) { for(i=0; i<(len / sizeof(*ireg)); i++) { @@ -90,6 +91,7 @@ ireg++; } } + of_node_put(np); return 1; } diff -Nru a/arch/ppc64/kernel/rtas-proc.c b/arch/ppc64/kernel/rtas-proc.c --- a/arch/ppc64/kernel/rtas-proc.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/rtas-proc.c Tue Sep 23 14:55:44 2003 @@ -200,7 +200,7 @@ { struct proc_dir_entry *entry; - rtas_node = find_devices("rtas"); + rtas_node = of_find_node_by_name(NULL, "rtas"); if ((rtas_node == NULL) || (systemcfg->platform == PLATFORM_ISERIES_LPAR)) { return; } diff -Nru a/arch/ppc64/kernel/rtasd.c b/arch/ppc64/kernel/rtasd.c --- a/arch/ppc64/kernel/rtasd.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/rtasd.c Tue Sep 23 14:55:44 2003 @@ -165,11 +165,12 @@ struct device_node *node; int *ip; - node = find_path_device("/rtas"); + node = of_find_node_by_path("/rtas"); ip = (int *)get_property(node, "rtas-event-scan-rate", NULL); if (ip == NULL) { printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n"); + of_node_put(node); return -1; } rtas_event_scan_rate = *ip; @@ -178,6 +179,7 @@ ip = (int *)get_property(node, "rtas-error-log-max", NULL); if (ip == NULL) { printk(KERN_ERR "rtasd: no rtas-error-log-max\n"); + of_node_put(node); return -1; } rtas_error_log_max = *ip; @@ -187,6 +189,7 @@ printk(KERN_ERR "rtasd: truncated error log from %d to %d bytes\n", rtas_error_log_max, RTAS_ERROR_LOG_MAX); rtas_error_log_max = RTAS_ERROR_LOG_MAX; } + of_node_put(node); return 0; } diff -Nru a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c --- a/arch/ppc64/kernel/setup.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/setup.c Tue Sep 23 14:55:44 2003 @@ -310,13 +310,14 @@ struct device_node *cpu_node; int *fp; - cpu_node = find_type_devices("cpu"); + cpu_node = of_find_node_by_type(NULL, "cpu"); if (cpu_node) { fp = (int *) get_property(cpu_node, "clock-frequency", NULL); if (fp) seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); + of_node_put(cpu_node); } } @@ -370,11 +371,12 @@ strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); #endif /* CONFIG_CMDLINE */ - chosen = find_devices("chosen"); + chosen = of_find_node_by_name(NULL, "chosen"); if (chosen != NULL) { p = get_property(chosen, "bootargs", NULL); if (p != NULL && p[0] != 0) strlcpy(cmd_line, p, sizeof(cmd_line)); + of_node_put(chosen); } /* Look for mem= option on command line */ diff -Nru a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c --- a/arch/ppc64/kernel/xics.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/kernel/xics.c Tue Sep 23 14:55:44 2003 @@ -405,7 +405,7 @@ ibm_int_on = rtas_token("ibm,int-on"); ibm_int_off = rtas_token("ibm,int-off"); - np = find_type_devices("PowerPC-External-Interrupt-Presentation"); + np = of_find_node_by_type(NULL, "PowerPC-External-Interrupt-Presentation"); if (!np) { printk(KERN_WARNING "Can't find Interrupt Presentation\n"); udbg_printf("Can't find Interrupt Presentation\n"); @@ -440,11 +440,13 @@ if (indx >= NR_CPUS) break; } - np = np->next; + np = of_find_node_by_type(np, "PowerPC-External-Interrupt-Presentation"); if ((indx < NR_CPUS) && np) goto nextnode; /* Find the server numbers for the boot cpu. */ - for (np = find_type_devices("cpu"); np; np = np->next) { + for (np = of_find_node_by_type(NULL, "cpu"); + np; + np = of_find_node_by_type(np, "cpu")) { ireg = (uint *)get_property(np, "reg", &ilen); if (ireg && ireg[0] == smp_processor_id()) { ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen); @@ -456,11 +458,12 @@ break; } } + of_node_put(np); intr_base = inodes[0].addr; intr_size = (ulong)inodes[0].size; - np = find_type_devices("interrupt-controller"); + np = of_find_node_by_type(NULL, "interrupt-controller"); if (!np) { printk(KERN_WARNING "xics: no ISA Interrupt Controller\n"); xics_irq_8259_cascade_real = -1; @@ -474,6 +477,7 @@ } xics_irq_8259_cascade_real = *ireg; xics_irq_8259_cascade = xics_irq_8259_cascade_real; + of_node_put(np); } if (systemcfg->platform == PLATFORM_PSERIES) { diff -Nru a/arch/ppc64/mm/numa.c b/arch/ppc64/mm/numa.c --- a/arch/ppc64/mm/numa.c Tue Sep 23 14:55:44 2003 +++ b/arch/ppc64/mm/numa.c Tue Sep 23 14:55:44 2003 @@ -45,29 +45,29 @@ static int __init parse_numa_properties(void) { - struct device_node *cpu; - struct device_node *memory; + struct device_node *cpu = NULL; + struct device_node *memory = NULL; int *cpu_associativity; int *memory_associativity; int depth; int max_domain = 0; - cpu = find_type_devices("cpu"); + cpu = of_find_node_by_type(NULL, "cpu"); if (!cpu) - return -1; + goto err; - memory = find_type_devices("memory"); + memory = of_find_node_by_type(NULL, "memory"); if (!memory) - return -1; + goto err; cpu_associativity = (int *)get_property(cpu, "ibm,associativity", NULL); if (!cpu_associativity) - return -1; + goto err; memory_associativity = (int *)get_property(memory, "ibm,associativity", NULL); if (!memory_associativity) - return -1; + goto err; /* find common depth */ if (cpu_associativity[0] < memory_associativity[0]) @@ -75,7 +75,7 @@ else depth = memory_associativity[0]; - for (cpu = find_type_devices("cpu"); cpu; cpu = cpu->next) { + for (; cpu; cpu = of_find_node_by_type(cpu, "cpu")) { int *tmp; int cpu_nr, numa_domain; @@ -105,8 +105,7 @@ map_cpu_to_node(cpu_nr, numa_domain); } - for (memory = find_type_devices("memory"); memory; - memory = memory->next) { + for (; memory; memory = of_find_node_by_type(memory, "memory")) { int *tmp1, *tmp2; unsigned long i; unsigned long start = 0; @@ -195,6 +194,10 @@ numnodes = max_domain + 1; return 0; +err: + of_node_put(cpu); + of_node_put(memory); + return -1; } void setup_nonnuma(void)