Commit 9f06f65e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: Rearrage interpret_funcs in C Order

From: Rusty Russell <rusty@rustcorp.com.au>

Rather than pre-declaring static functions, order them so it's not neccessary.
This makes the code easier to navigate and patch.
parent cde5f62f
...@@ -124,11 +124,6 @@ struct pci_intr_map { ...@@ -124,11 +124,6 @@ struct pci_intr_map {
typedef unsigned long interpret_func(struct device_node *, unsigned long, typedef unsigned long interpret_func(struct device_node *, unsigned long,
int, int); int, int);
static interpret_func interpret_pci_props;
static interpret_func interpret_isa_props;
static interpret_func interpret_root_props;
static interpret_func interpret_dbdma_props;
static interpret_func interpret_macio_props;
#ifndef FB_MAX /* avoid pulling in all of the fb stuff */ #ifndef FB_MAX /* avoid pulling in all of the fb stuff */
#define FB_MAX 8 #define FB_MAX 8
...@@ -2123,122 +2118,6 @@ finish_node_interrupts(struct device_node *np, unsigned long mem_start) ...@@ -2123,122 +2118,6 @@ finish_node_interrupts(struct device_node *np, unsigned long mem_start)
return mem_start; return mem_start;
} }
static unsigned long __init
finish_node(struct device_node *np, unsigned long mem_start,
interpret_func *ifunc, int naddrc, int nsizec)
{
struct device_node *child;
int *ip;
np->name = get_property(np, "name", 0);
np->type = get_property(np, "device_type", 0);
if (!np->name)
np->name = "<NULL>";
if (!np->type)
np->type = "<NULL>";
/* get the device addresses and interrupts */
if (ifunc != NULL)
mem_start = ifunc(np, mem_start, naddrc, nsizec);
mem_start = finish_node_interrupts(np, mem_start);
/* Look for #address-cells and #size-cells properties. */
ip = (int *) get_property(np, "#address-cells", 0);
if (ip != NULL)
naddrc = *ip;
ip = (int *) get_property(np, "#size-cells", 0);
if (ip != NULL)
nsizec = *ip;
/* the f50 sets the name to 'display' and 'compatible' to what we
* expect for the name -- Cort
*/
if (!strcmp(np->name, "display"))
np->name = get_property(np, "compatible", 0);
if (!strcmp(np->name, "device-tree") || np->parent == NULL)
ifunc = interpret_root_props;
else if (np->type == 0)
ifunc = NULL;
else if (!strcmp(np->type, "pci") || !strcmp(np->type, "vci"))
ifunc = interpret_pci_props;
else if (!strcmp(np->type, "dbdma"))
ifunc = interpret_dbdma_props;
else if (!strcmp(np->type, "mac-io") || ifunc == interpret_macio_props)
ifunc = interpret_macio_props;
else if (!strcmp(np->type, "isa"))
ifunc = interpret_isa_props;
else if (!strcmp(np->name, "uni-n") || !strcmp(np->name, "u3"))
ifunc = interpret_root_props;
else if (!((ifunc == interpret_dbdma_props
|| ifunc == interpret_macio_props)
&& (!strcmp(np->type, "escc")
|| !strcmp(np->type, "media-bay"))))
ifunc = NULL;
for (child = np->child; child != NULL; child = child->sibling)
mem_start = finish_node(child, mem_start, ifunc,
naddrc, nsizec);
return mem_start;
}
/*
* finish_device_tree is called once things are running normally
* (i.e. with text and data mapped to the address they were linked at).
* It traverses the device tree and fills in the name, type,
* {n_}addrs and {n_}intrs fields of each node.
*/
void __init
finish_device_tree(void)
{
unsigned long mem = klimit;
virt_irq_init();
mem = finish_node(allnodes, mem, NULL, 0, 0);
dev_tree_size = mem - (unsigned long) allnodes;
mem = _ALIGN(mem, PAGE_SIZE);
lmb_reserve(__pa(klimit), mem-klimit);
klimit = mem;
rtas.dev = of_find_node_by_name(NULL, "rtas");
}
int
prom_n_addr_cells(struct device_node* np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = (int *) get_property(np, "#address-cells", 0);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #address-cells property for the root node, default to 1 */
return 1;
}
int
prom_n_size_cells(struct device_node* np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = (int *) get_property(np, "#size-cells", 0);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #size-cells property for the root node, default to 1 */
return 1;
}
static unsigned long __init static unsigned long __init
interpret_pci_props(struct device_node *np, unsigned long mem_start, interpret_pci_props(struct device_node *np, unsigned long mem_start,
int naddrc, int nsizec) int naddrc, int nsizec)
...@@ -2391,6 +2270,122 @@ interpret_root_props(struct device_node *np, unsigned long mem_start, ...@@ -2391,6 +2270,122 @@ interpret_root_props(struct device_node *np, unsigned long mem_start,
return mem_start; return mem_start;
} }
static unsigned long __init
finish_node(struct device_node *np, unsigned long mem_start,
interpret_func *ifunc, int naddrc, int nsizec)
{
struct device_node *child;
int *ip;
np->name = get_property(np, "name", 0);
np->type = get_property(np, "device_type", 0);
if (!np->name)
np->name = "<NULL>";
if (!np->type)
np->type = "<NULL>";
/* get the device addresses and interrupts */
if (ifunc != NULL)
mem_start = ifunc(np, mem_start, naddrc, nsizec);
mem_start = finish_node_interrupts(np, mem_start);
/* Look for #address-cells and #size-cells properties. */
ip = (int *) get_property(np, "#address-cells", 0);
if (ip != NULL)
naddrc = *ip;
ip = (int *) get_property(np, "#size-cells", 0);
if (ip != NULL)
nsizec = *ip;
/* the f50 sets the name to 'display' and 'compatible' to what we
* expect for the name -- Cort
*/
if (!strcmp(np->name, "display"))
np->name = get_property(np, "compatible", 0);
if (!strcmp(np->name, "device-tree") || np->parent == NULL)
ifunc = interpret_root_props;
else if (np->type == 0)
ifunc = NULL;
else if (!strcmp(np->type, "pci") || !strcmp(np->type, "vci"))
ifunc = interpret_pci_props;
else if (!strcmp(np->type, "dbdma"))
ifunc = interpret_dbdma_props;
else if (!strcmp(np->type, "mac-io") || ifunc == interpret_macio_props)
ifunc = interpret_macio_props;
else if (!strcmp(np->type, "isa"))
ifunc = interpret_isa_props;
else if (!strcmp(np->name, "uni-n") || !strcmp(np->name, "u3"))
ifunc = interpret_root_props;
else if (!((ifunc == interpret_dbdma_props
|| ifunc == interpret_macio_props)
&& (!strcmp(np->type, "escc")
|| !strcmp(np->type, "media-bay"))))
ifunc = NULL;
for (child = np->child; child != NULL; child = child->sibling)
mem_start = finish_node(child, mem_start, ifunc,
naddrc, nsizec);
return mem_start;
}
/*
* finish_device_tree is called once things are running normally
* (i.e. with text and data mapped to the address they were linked at).
* It traverses the device tree and fills in the name, type,
* {n_}addrs and {n_}intrs fields of each node.
*/
void __init
finish_device_tree(void)
{
unsigned long mem = klimit;
virt_irq_init();
mem = finish_node(allnodes, mem, NULL, 0, 0);
dev_tree_size = mem - (unsigned long) allnodes;
mem = _ALIGN(mem, PAGE_SIZE);
lmb_reserve(__pa(klimit), mem-klimit);
klimit = mem;
rtas.dev = of_find_node_by_name(NULL, "rtas");
}
int
prom_n_addr_cells(struct device_node* np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = (int *) get_property(np, "#address-cells", 0);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #address-cells property for the root node, default to 1 */
return 1;
}
int
prom_n_size_cells(struct device_node* np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = (int *) get_property(np, "#size-cells", 0);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #size-cells property for the root node, default to 1 */
return 1;
}
/* /*
* Work out the sense (active-low level / active-high edge) * Work out the sense (active-low level / active-high edge)
* of each interrupt from the device tree. * of each interrupt from the device tree.
......
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