Commit 40399e6d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: Change to new OF device tree API, from Nathan Lynch

From: Anton Blanchard <anton@samba.org>

Attached is a patch which replaces all the uses of the old device tree API in
arch/ppc64.  Patch is against 2.6.0-test5 (cset 1.1328) from ameslab bk, plus
the patch from my previous message.  I've tested this on a pSeries LPAR.
parent 4e0cbcfe
...@@ -96,16 +96,19 @@ chrp_get_cpuinfo(struct seq_file *m) ...@@ -96,16 +96,19 @@ chrp_get_cpuinfo(struct seq_file *m)
seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq); seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
root = find_path_device("/"); root = of_find_node_by_path("/");
if (root) if (root)
model = get_property(root, "model", NULL); model = get_property(root, "model", NULL);
seq_printf(m, "machine\t\t: CHRP %s\n", model); seq_printf(m, "machine\t\t: CHRP %s\n", model);
of_node_put(root);
} }
#define I8042_DATA_REG 0x60 #define I8042_DATA_REG 0x60
void __init chrp_request_regions(void) void __init chrp_request_regions(void)
{ {
struct device_node *i8042;
request_region(0x20,0x20,"pic1"); request_region(0x20,0x20,"pic1");
request_region(0xa0,0x20,"pic2"); request_region(0xa0,0x20,"pic2");
request_region(0x00,0x20,"dma1"); request_region(0x00,0x20,"dma1");
...@@ -118,8 +121,9 @@ void __init chrp_request_regions(void) ...@@ -118,8 +121,9 @@ void __init chrp_request_regions(void)
* tree and reserve the region if it does not appear. Later on * tree and reserve the region if it does not appear. Later on
* the i8042 code will try and reserve this region and fail. * 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)"); request_region(I8042_DATA_REG, 16, "reserved (no i8042)");
of_node_put(i8042);
} }
void __init void __init
...@@ -158,7 +162,7 @@ chrp_setup_arch(void) ...@@ -158,7 +162,7 @@ chrp_setup_arch(void)
#endif #endif
/* Find the Open PIC if present */ /* Find the Open PIC if present */
root = find_path_device("/"); root = of_find_node_by_path("/");
opprop = (unsigned int *) get_property(root, opprop = (unsigned int *) get_property(root,
"platform-open-pic", NULL); "platform-open-pic", NULL);
if (opprop != 0) { if (opprop != 0) {
...@@ -170,6 +174,7 @@ chrp_setup_arch(void) ...@@ -170,6 +174,7 @@ chrp_setup_arch(void)
printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic); printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic);
OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE); OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE);
} }
of_node_put(root);
#ifdef CONFIG_DUMMY_CONSOLE #ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con; conswitchp = &dummy_con;
...@@ -271,7 +276,7 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -271,7 +276,7 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
struct device_node * dn; struct device_node * dn;
char * hypertas; char * hypertas;
unsigned int len; unsigned int len;
dn = find_path_device("/rtas"); dn = of_find_node_by_path("/rtas");
cur_cpu_spec->firmware_features = 0; cur_cpu_spec->firmware_features = 0;
hypertas = get_property(dn, "ibm,hypertas-functions", &len); hypertas = get_property(dn, "ibm,hypertas-functions", &len);
if (hypertas) { if (hypertas) {
...@@ -290,6 +295,7 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -290,6 +295,7 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
hypertas+= hypertas_len +1; hypertas+= hypertas_len +1;
} }
} }
of_node_put(dn);
udbg_printf("firmware_features bitmask: 0x%x \n", udbg_printf("firmware_features bitmask: 0x%x \n",
cur_cpu_spec->firmware_features); cur_cpu_spec->firmware_features);
} }
...@@ -405,11 +411,11 @@ void __init pSeries_calibrate_decr(void) ...@@ -405,11 +411,11 @@ void __init pSeries_calibrate_decr(void)
/* /*
* The cpu node should have a timebase-frequency property * The cpu node should have a timebase-frequency property
* to tell us the rate at which the decrementer counts. * to tell us the rate at which the decrementer counts.
*/ */
freq = 16666000; /* hardcoded default */ freq = 16666000; /* hardcoded default */
cpu = find_type_devices("cpu"); cpu = of_find_node_by_type(NULL, "cpu");
if (cpu != 0) { if (cpu != 0) {
fp = (int *) get_property(cpu, "timebase-frequency", NULL); fp = (int *) get_property(cpu, "timebase-frequency", NULL);
if (fp != 0) if (fp != 0)
freq = *fp; freq = *fp;
...@@ -422,11 +428,12 @@ void __init pSeries_calibrate_decr(void) ...@@ -422,11 +428,12 @@ void __init pSeries_calibrate_decr(void)
processor_freq = *fp; processor_freq = *fp;
} }
ppc_proc_freq = processor_freq; ppc_proc_freq = processor_freq;
of_node_put(cpu);
printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
freq/1000000, freq%1000000 ); printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
freq/1000000, freq%1000000);
printk("time_init: processor frequency = %lu.%.6lu MHz\n", printk("time_init: processor frequency = %lu.%.6lu MHz\n",
processor_freq/1000000, processor_freq%1000000 ); processor_freq/1000000, processor_freq%1000000);
tb_ticks_per_jiffy = freq / HZ; tb_ticks_per_jiffy = freq / HZ;
tb_ticks_per_sec = tb_ticks_per_jiffy * HZ; tb_ticks_per_sec = tb_ticks_per_jiffy * HZ;
......
...@@ -257,7 +257,7 @@ void eeh_init(void) ...@@ -257,7 +257,7 @@ void eeh_init(void)
/* Enable EEH for all adapters. Note that eeh requires buid's */ /* Enable EEH for all adapters. Note that eeh requires buid's */
info.adapters_enabled = 0; 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 len;
int *buid_vals = (int *) get_property(phb, "ibm,fw-phb-id", &len); int *buid_vals = (int *) get_property(phb, "ibm,fw-phb-id", &len);
if (!buid_vals) if (!buid_vals)
......
...@@ -116,7 +116,7 @@ int __init nvram_init(void) ...@@ -116,7 +116,7 @@ int __init nvram_init(void)
{ {
struct device_node *nvram; struct device_node *nvram;
unsigned int *nbytes_p, proplen; 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); nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen);
if (nbytes_p && proplen == sizeof(unsigned int)) { if (nbytes_p && proplen == sizeof(unsigned int)) {
rtas_nvram_size = *nbytes_p; rtas_nvram_size = *nbytes_p;
...@@ -125,6 +125,7 @@ int __init nvram_init(void) ...@@ -125,6 +125,7 @@ int __init nvram_init(void)
nvram_fetch = rtas_token("nvram-fetch"); nvram_fetch = rtas_token("nvram-fetch");
nvram_store = rtas_token("nvram-store"); nvram_store = rtas_token("nvram-store");
printk(KERN_INFO "PPC64 nvram contains %d bytes\n", rtas_nvram_size); printk(KERN_INFO "PPC64 nvram contains %d bytes\n", rtas_nvram_size);
of_node_put(nvram);
return misc_register(&nvram_dev); return misc_register(&nvram_dev);
} }
......
...@@ -142,7 +142,7 @@ void __init openpic_init_IRQ(void) ...@@ -142,7 +142,7 @@ void __init openpic_init_IRQ(void)
struct device_node *kbd; struct device_node *kbd;
#endif #endif
if (!(np = find_devices("pci")) if (!(np = of_find_node_by_name(NULL, "pci"))
|| !(addrp = (unsigned int *) || !(addrp = (unsigned int *)
get_property(np, "8259-interrupt-acknowledge", NULL))) get_property(np, "8259-interrupt-acknowledge", NULL)))
printk(KERN_ERR "Cannot find pci to get ack address\n"); printk(KERN_ERR "Cannot find pci to get ack address\n");
...@@ -158,6 +158,7 @@ void __init openpic_init_IRQ(void) ...@@ -158,6 +158,7 @@ void __init openpic_init_IRQ(void)
openpic_init(1, NUM_8259_INTERRUPTS, chrp_int_ack_special, nmi_irq); openpic_init(1, NUM_8259_INTERRUPTS, chrp_int_ack_special, nmi_irq);
for ( i = 0 ; i < NUM_8259_INTERRUPTS ; i++ ) for ( i = 0 ; i < NUM_8259_INTERRUPTS ; i++ )
irq_desc[i].handler = &i8259_pic; irq_desc[i].handler = &i8259_pic;
of_node_put(np);
} }
static inline u_int openpic_read(volatile u_int *addr) static inline u_int openpic_read(volatile u_int *addr)
......
...@@ -389,10 +389,11 @@ void hpte_init_pSeries(void) ...@@ -389,10 +389,11 @@ void hpte_init_pSeries(void)
ppc_md.hpte_remove = pSeries_hpte_remove; ppc_md.hpte_remove = pSeries_hpte_remove;
/* Disable TLB batching on nighthawk */ /* Disable TLB batching on nighthawk */
root = find_path_device("/"); root = of_find_node_by_path("/");
if (root) { if (root) {
model = get_property(root, "model", NULL); model = get_property(root, "model", NULL);
if (strcmp(model, "CHRP IBM,9076-N81")) if (strcmp(model, "CHRP IBM,9076-N81"))
ppc_md.flush_hash_range = pSeries_flush_hash_range; ppc_md.flush_hash_range = pSeries_flush_hash_range;
of_node_put(root);
} }
} }
...@@ -234,11 +234,12 @@ void pSeriesLP_init_early(void) ...@@ -234,11 +234,12 @@ void pSeriesLP_init_early(void)
* is the starting termno (the one we use) and the second is the * is the starting termno (the one we use) and the second is the
* number of terminals. * number of terminals.
*/ */
np = find_path_device("/rtas"); np = of_find_node_by_path("/rtas");
if (np) { if (np) {
u32 *termno = (u32 *)get_property(np, "ibm,termno", 0); u32 *termno = (u32 *)get_property(np, "ibm,termno", 0);
if (termno) if (termno)
vtermno = termno[0]; vtermno = termno[0];
of_node_put(np);
} }
ppc_md.udbg_putc = udbg_putcLP; ppc_md.udbg_putc = udbg_putcLP;
ppc_md.udbg_getc = udbg_getcLP; ppc_md.udbg_getc = udbg_getcLP;
...@@ -289,15 +290,17 @@ int hvc_count(int *start_termno) ...@@ -289,15 +290,17 @@ int hvc_count(int *start_termno)
{ {
u32 *termno; u32 *termno;
struct device_node *dn; 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 ((termno = (u32 *)get_property(dn, "ibm,termno", 0)) != NULL) {
if (start_termno) if (start_termno)
*start_termno = termno[0]; *start_termno = termno[0];
return termno[1]; ret = termno[1];
} }
of_node_put(dn);
} }
return 0; return ret;
} }
......
...@@ -188,6 +188,7 @@ static void __init pci_process_bridge_OF_ranges(struct pci_controller *hose, ...@@ -188,6 +188,7 @@ static void __init pci_process_bridge_OF_ranges(struct pci_controller *hose,
struct resource *res; struct resource *res;
int np, na = prom_n_addr_cells(dev); int np, na = prom_n_addr_cells(dev);
unsigned long pci_addr, cpu_phys_addr; unsigned long pci_addr, cpu_phys_addr;
struct device_node *isa_dn;
np = na + 5; np = na + 5;
...@@ -219,8 +220,11 @@ static void __init pci_process_bridge_OF_ranges(struct pci_controller *hose, ...@@ -219,8 +220,11 @@ static void __init pci_process_bridge_OF_ranges(struct pci_controller *hose,
size, _PAGE_NO_CACHE); size, _PAGE_NO_CACHE);
if (primary) { if (primary) {
pci_io_base = (unsigned long)hose->io_base_virt; 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; isa_io_base = pci_io_base;
of_node_put(isa_dn);
}
} }
res = &hose->io_resource; res = &hose->io_resource;
...@@ -386,7 +390,7 @@ unsigned long __init find_and_init_phbs(void) ...@@ -386,7 +390,7 @@ unsigned long __init find_and_init_phbs(void)
unsigned int root_size_cells = 0; unsigned int root_size_cells = 0;
unsigned int index; unsigned int index;
unsigned int *opprop; 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"); read_pci_config = rtas_token("read-pci-config");
write_pci_config = rtas_token("write-pci-config"); write_pci_config = rtas_token("write-pci-config");
...@@ -402,7 +406,9 @@ unsigned long __init find_and_init_phbs(void) ...@@ -402,7 +406,9 @@ unsigned long __init find_and_init_phbs(void)
index = 0; 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) if (node->type == NULL || strcmp(node->type, "pci") != 0)
continue; continue;
...@@ -420,6 +426,7 @@ unsigned long __init find_and_init_phbs(void) ...@@ -420,6 +426,7 @@ unsigned long __init find_and_init_phbs(void)
index++; index++;
} }
of_node_put(root);
pci_devs_phb_init(); pci_devs_phb_init();
return 0; return 0;
...@@ -525,11 +532,12 @@ static void check_s7a(void) ...@@ -525,11 +532,12 @@ static void check_s7a(void)
struct device_node *root; struct device_node *root;
char *model; char *model;
root = find_path_device("/"); root = of_find_node_by_path("/");
if (root) { if (root) {
model = get_property(root, "model", NULL); model = get_property(root, "model", NULL);
if (model && !strcmp(model, "IBM,7013-S7A")) if (model && !strcmp(model, "IBM,7013-S7A"))
s7a_workaround = 1; s7a_workaround = 1;
of_node_put(root);
} }
} }
......
...@@ -1504,7 +1504,7 @@ finish_device_tree(void) ...@@ -1504,7 +1504,7 @@ finish_device_tree(void)
klimit = mem; klimit = mem;
rtas.dev = find_devices("rtas"); rtas.dev = of_find_node_by_name(NULL, "rtas");
} }
static unsigned long __init static unsigned long __init
...@@ -1956,11 +1956,14 @@ int ...@@ -1956,11 +1956,14 @@ int
machine_is_compatible(const char *compat) machine_is_compatible(const char *compat)
{ {
struct device_node *root; struct device_node *root;
int rc = 0;
root = find_path_device("/");
if (root == 0) root = of_find_node_by_path("/");
return 0; if (root) {
return device_is_compatible(root, compat); rc = device_is_compatible(root, compat);
of_node_put(root);
}
return rc;
} }
/* /*
......
...@@ -70,27 +70,29 @@ static int __init init_ras_IRQ(void) ...@@ -70,27 +70,29 @@ static int __init init_ras_IRQ(void)
struct device_node *np; struct device_node *np;
unsigned int *ireg, len, i; 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", (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
&len))) { &len))) {
for(i=0; i<(len / sizeof(*ireg)); i++) { for (i=0; i<(len / sizeof(*ireg)); i++) {
request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS, request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS,
ras_error_interrupt, 0, ras_error_interrupt, 0,
"RAS_ERROR", NULL); "RAS_ERROR", NULL);
ireg++; 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", (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
&len))) { &len))) {
for(i=0; i<(len / sizeof(*ireg)); i++) { for (i=0; i<(len / sizeof(*ireg)); i++) {
request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS, request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS,
ras_epow_interrupt, 0, ras_epow_interrupt, 0,
"RAS_EPOW", NULL); "RAS_EPOW", NULL);
ireg++; ireg++;
} }
} }
of_node_put(np);
return 1; return 1;
} }
......
...@@ -200,7 +200,7 @@ void proc_rtas_init(void) ...@@ -200,7 +200,7 @@ void proc_rtas_init(void)
{ {
struct proc_dir_entry *entry; 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)) { if ((rtas_node == NULL) || (systemcfg->platform == PLATFORM_ISERIES_LPAR)) {
return; return;
} }
......
...@@ -165,11 +165,12 @@ static int get_eventscan_parms(void) ...@@ -165,11 +165,12 @@ static int get_eventscan_parms(void)
struct device_node *node; struct device_node *node;
int *ip; int *ip;
node = find_path_device("/rtas"); node = of_find_node_by_path("/rtas");
ip = (int *)get_property(node, "rtas-event-scan-rate", NULL); ip = (int *)get_property(node, "rtas-event-scan-rate", NULL);
if (ip == NULL) { if (ip == NULL) {
printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n"); printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n");
of_node_put(node);
return -1; return -1;
} }
rtas_event_scan_rate = *ip; rtas_event_scan_rate = *ip;
...@@ -178,6 +179,7 @@ static int get_eventscan_parms(void) ...@@ -178,6 +179,7 @@ static int get_eventscan_parms(void)
ip = (int *)get_property(node, "rtas-error-log-max", NULL); ip = (int *)get_property(node, "rtas-error-log-max", NULL);
if (ip == NULL) { if (ip == NULL) {
printk(KERN_ERR "rtasd: no rtas-error-log-max\n"); printk(KERN_ERR "rtasd: no rtas-error-log-max\n");
of_node_put(node);
return -1; return -1;
} }
rtas_error_log_max = *ip; rtas_error_log_max = *ip;
...@@ -187,6 +189,7 @@ static int get_eventscan_parms(void) ...@@ -187,6 +189,7 @@ static int get_eventscan_parms(void)
printk(KERN_ERR "rtasd: truncated error log from %d to %d bytes\n", rtas_error_log_max, RTAS_ERROR_LOG_MAX); 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; rtas_error_log_max = RTAS_ERROR_LOG_MAX;
} }
of_node_put(node);
return 0; return 0;
} }
......
...@@ -315,13 +315,14 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -315,13 +315,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
struct device_node *cpu_node; struct device_node *cpu_node;
int *fp; int *fp;
cpu_node = find_type_devices("cpu"); cpu_node = of_find_node_by_type(NULL, "cpu");
if (cpu_node) { if (cpu_node) {
fp = (int *) get_property(cpu_node, "clock-frequency", fp = (int *) get_property(cpu_node, "clock-frequency",
NULL); NULL);
if (fp) if (fp)
seq_printf(m, "clock\t\t: %dMHz\n", seq_printf(m, "clock\t\t: %dMHz\n",
*fp / 1000000); *fp / 1000000);
of_node_put(cpu_node);
} }
} }
...@@ -375,11 +376,12 @@ void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -375,11 +376,12 @@ void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
#endif /* CONFIG_CMDLINE */ #endif /* CONFIG_CMDLINE */
chosen = find_devices("chosen"); chosen = of_find_node_by_name(NULL, "chosen");
if (chosen != NULL) { if (chosen != NULL) {
p = get_property(chosen, "bootargs", NULL); p = get_property(chosen, "bootargs", NULL);
if (p != NULL && p[0] != 0) if (p != NULL && p[0] != 0)
strlcpy(cmd_line, p, sizeof(cmd_line)); strlcpy(cmd_line, p, sizeof(cmd_line));
of_node_put(chosen);
} }
/* Look for mem= option on command line */ /* Look for mem= option on command line */
......
...@@ -398,7 +398,7 @@ void xics_init_IRQ(void) ...@@ -398,7 +398,7 @@ void xics_init_IRQ(void)
ibm_int_on = rtas_token("ibm,int-on"); ibm_int_on = rtas_token("ibm,int-on");
ibm_int_off = rtas_token("ibm,int-off"); 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) { if (!np) {
printk(KERN_WARNING "Can't find Interrupt Presentation\n"); printk(KERN_WARNING "Can't find Interrupt Presentation\n");
udbg_printf("Can't find Interrupt Presentation\n"); udbg_printf("Can't find Interrupt Presentation\n");
...@@ -433,11 +433,13 @@ void xics_init_IRQ(void) ...@@ -433,11 +433,13 @@ void xics_init_IRQ(void)
if (indx >= NR_CPUS) break; 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; if ((indx < NR_CPUS) && np) goto nextnode;
/* Find the server numbers for the boot cpu. */ /* 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); ireg = (uint *)get_property(np, "reg", &ilen);
if (ireg && ireg[0] == smp_processor_id()) { if (ireg && ireg[0] == smp_processor_id()) {
ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen); ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
...@@ -449,11 +451,12 @@ void xics_init_IRQ(void) ...@@ -449,11 +451,12 @@ void xics_init_IRQ(void)
break; break;
} }
} }
of_node_put(np);
intr_base = inodes[0].addr; intr_base = inodes[0].addr;
intr_size = (ulong)inodes[0].size; intr_size = (ulong)inodes[0].size;
np = find_type_devices("interrupt-controller"); np = of_find_node_by_type(NULL, "interrupt-controller");
if (!np) { if (!np) {
printk(KERN_WARNING "xics: no ISA Interrupt Controller\n"); printk(KERN_WARNING "xics: no ISA Interrupt Controller\n");
xics_irq_8259_cascade_real = -1; xics_irq_8259_cascade_real = -1;
...@@ -467,6 +470,7 @@ void xics_init_IRQ(void) ...@@ -467,6 +470,7 @@ void xics_init_IRQ(void)
} }
xics_irq_8259_cascade_real = *ireg; xics_irq_8259_cascade_real = *ireg;
xics_irq_8259_cascade = virt_irq_create_mapping(xics_irq_8259_cascade_real); xics_irq_8259_cascade = virt_irq_create_mapping(xics_irq_8259_cascade_real);
of_node_put(np);
} }
if (systemcfg->platform == PLATFORM_PSERIES) { if (systemcfg->platform == PLATFORM_PSERIES) {
......
...@@ -46,29 +46,29 @@ static inline void map_cpu_to_node(int cpu, int node) ...@@ -46,29 +46,29 @@ static inline void map_cpu_to_node(int cpu, int node)
static int __init parse_numa_properties(void) static int __init parse_numa_properties(void)
{ {
struct device_node *cpu; struct device_node *cpu = NULL;
struct device_node *memory; struct device_node *memory = NULL;
int *cpu_associativity; int *cpu_associativity;
int *memory_associativity; int *memory_associativity;
int depth; int depth;
int max_domain = 0; int max_domain = 0;
cpu = find_type_devices("cpu"); cpu = of_find_node_by_type(NULL, "cpu");
if (!cpu) if (!cpu)
return -1; goto err;
memory = find_type_devices("memory"); memory = of_find_node_by_type(NULL, "memory");
if (!memory) if (!memory)
return -1; goto err;
cpu_associativity = (int *)get_property(cpu, "ibm,associativity", NULL); cpu_associativity = (int *)get_property(cpu, "ibm,associativity", NULL);
if (!cpu_associativity) if (!cpu_associativity)
return -1; goto err;
memory_associativity = (int *)get_property(memory, "ibm,associativity", memory_associativity = (int *)get_property(memory, "ibm,associativity",
NULL); NULL);
if (!memory_associativity) if (!memory_associativity)
return -1; goto err;
/* find common depth */ /* find common depth */
if (cpu_associativity[0] < memory_associativity[0]) if (cpu_associativity[0] < memory_associativity[0])
...@@ -76,7 +76,7 @@ static int __init parse_numa_properties(void) ...@@ -76,7 +76,7 @@ static int __init parse_numa_properties(void)
else else
depth = memory_associativity[0]; 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 *tmp;
int cpu_nr, numa_domain; int cpu_nr, numa_domain;
...@@ -106,8 +106,7 @@ static int __init parse_numa_properties(void) ...@@ -106,8 +106,7 @@ static int __init parse_numa_properties(void)
map_cpu_to_node(cpu_nr, numa_domain); map_cpu_to_node(cpu_nr, numa_domain);
} }
for (memory = find_type_devices("memory"); memory; for (; memory; memory = of_find_node_by_type(memory, "memory")) {
memory = memory->next) {
int *tmp1, *tmp2; int *tmp1, *tmp2;
unsigned long i; unsigned long i;
unsigned long start = 0; unsigned long start = 0;
...@@ -196,6 +195,10 @@ static int __init parse_numa_properties(void) ...@@ -196,6 +195,10 @@ static int __init parse_numa_properties(void)
numnodes = max_domain + 1; numnodes = max_domain + 1;
return 0; return 0;
err:
of_node_put(cpu);
of_node_put(memory);
return -1;
} }
void setup_nonnuma(void) void setup_nonnuma(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment