Commit 74761bb5 authored by Mike Kravetz's avatar Mike Kravetz Committed by Paul Mackerras

[PATCH] powerpc: Minor numa memory code cleanup

I started to add missing of_node_put() calls to the routines that
determine the number of cells for memory.  Decided to combine the
routines instead of making separate node lookups.  Changed variable
names to help with some confusion as to meaning.
Signed-off-by: default avatarMike Kravetz <kravetz@us.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 8dacaedf
...@@ -254,29 +254,17 @@ static int __init find_min_common_depth(void) ...@@ -254,29 +254,17 @@ static int __init find_min_common_depth(void)
return depth; return depth;
} }
static int __init get_mem_addr_cells(void) static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
{ {
struct device_node *memory = NULL; struct device_node *memory = NULL;
int rc;
memory = of_find_node_by_type(memory, "memory"); memory = of_find_node_by_type(memory, "memory");
if (!memory) if (memory) {
return 0; /* it won't matter */ *n_addr_cells = prom_n_addr_cells(memory);
*n_size_cells = prom_n_size_cells(memory);
rc = prom_n_addr_cells(memory); of_node_put(memory);
return rc; }
} /* if (!memory) we are in trouble, let other code error out */
static int __init get_mem_size_cells(void)
{
struct device_node *memory = NULL;
int rc;
memory = of_find_node_by_type(memory, "memory");
if (!memory)
return 0; /* it won't matter */
rc = prom_n_size_cells(memory);
return rc;
} }
static unsigned long __init read_n_cells(int n, unsigned int **buf) static unsigned long __init read_n_cells(int n, unsigned int **buf)
...@@ -386,7 +374,7 @@ static int __init parse_numa_properties(void) ...@@ -386,7 +374,7 @@ static int __init parse_numa_properties(void)
{ {
struct device_node *cpu = NULL; struct device_node *cpu = NULL;
struct device_node *memory = NULL; struct device_node *memory = NULL;
int addr_cells, size_cells; int n_addr_cells, n_size_cells;
int max_domain; int max_domain;
unsigned long i; unsigned long i;
...@@ -425,8 +413,7 @@ static int __init parse_numa_properties(void) ...@@ -425,8 +413,7 @@ static int __init parse_numa_properties(void)
} }
} }
addr_cells = get_mem_addr_cells(); get_n_mem_cells(&n_addr_cells, &n_size_cells);
size_cells = get_mem_size_cells();
memory = NULL; memory = NULL;
while ((memory = of_find_node_by_type(memory, "memory")) != NULL) { while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
unsigned long start; unsigned long start;
...@@ -443,8 +430,8 @@ static int __init parse_numa_properties(void) ...@@ -443,8 +430,8 @@ static int __init parse_numa_properties(void)
ranges = memory->n_addrs; ranges = memory->n_addrs;
new_range: new_range:
/* these are order-sensitive, and modify the buffer pointer */ /* these are order-sensitive, and modify the buffer pointer */
start = read_n_cells(addr_cells, &memcell_buf); start = read_n_cells(n_addr_cells, &memcell_buf);
size = read_n_cells(size_cells, &memcell_buf); size = read_n_cells(n_size_cells, &memcell_buf);
numa_domain = of_node_numa_domain(memory); numa_domain = of_node_numa_domain(memory);
......
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