diff options
author | Andres Salomon <dilinger@queued.net> | 2010-10-10 23:49:45 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-10-12 23:57:53 -0400 |
commit | f90c34bd658d240cb5ebc5fe0a17796e590c6ec8 (patch) | |
tree | 02e8243910e156d3af4a14bd9be63dd829d07576 /arch | |
parent | 3cfc535c5df8122af1258ae05aaf2770c033425d (diff) |
of/promtree: no longer call prom_ functions directly; use an ops structure
Rather than assuming an architecture defines prom_getchild and friends,
define an ops struct with hooks for the various prom functions that
pdt.c needs. This ops struct is filled in by the
arch-(and sometimes firmware-)specific code, and passed to
of_pdt_build_devicetree.
Update sparc code to define the ops struct as well.
Signed-off-by: Andres Salomon <dilinger@queued.net>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc/kernel/prom_common.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c index fe84d56b7c5a..ed25834328f4 100644 --- a/arch/sparc/kernel/prom_common.c +++ b/arch/sparc/kernel/prom_common.c | |||
@@ -118,11 +118,45 @@ int of_find_in_proplist(const char *list, const char *match, int len) | |||
118 | } | 118 | } |
119 | EXPORT_SYMBOL(of_find_in_proplist); | 119 | EXPORT_SYMBOL(of_find_in_proplist); |
120 | 120 | ||
121 | /* | ||
122 | * SPARC32 and SPARC64's prom_nextprop() do things differently | ||
123 | * here, despite sharing the same interface. SPARC32 doesn't fill in 'buf', | ||
124 | * returning NULL on an error. SPARC64 fills in 'buf', but sets it to an | ||
125 | * empty string upon error. | ||
126 | */ | ||
127 | static int __init handle_nextprop_quirks(char *buf, const char *name) | ||
128 | { | ||
129 | if (!name || strlen(name) == 0) | ||
130 | return -1; | ||
131 | |||
132 | #ifdef CONFIG_SPARC32 | ||
133 | strcpy(buf, name); | ||
134 | #endif | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static int __init prom_common_nextprop(phandle node, char *prev, char *buf) | ||
139 | { | ||
140 | const char *name; | ||
141 | |||
142 | buf[0] = '\0'; | ||
143 | name = prom_nextprop(node, prev, buf); | ||
144 | return handle_nextprop_quirks(buf, name); | ||
145 | } | ||
146 | |||
121 | unsigned int prom_early_allocated __initdata; | 147 | unsigned int prom_early_allocated __initdata; |
122 | 148 | ||
149 | static struct of_pdt_ops prom_sparc_ops __initdata = { | ||
150 | .nextprop = prom_common_nextprop, | ||
151 | .getproplen = prom_getproplen, | ||
152 | .getproperty = prom_getproperty, | ||
153 | .getchild = prom_getchild, | ||
154 | .getsibling = prom_getsibling, | ||
155 | }; | ||
156 | |||
123 | void __init prom_build_devicetree(void) | 157 | void __init prom_build_devicetree(void) |
124 | { | 158 | { |
125 | of_pdt_build_devicetree(prom_root_node); | 159 | of_pdt_build_devicetree(prom_root_node, &prom_sparc_ops); |
126 | of_console_init(); | 160 | of_console_init(); |
127 | 161 | ||
128 | pr_info("PROM: Built device tree with %u bytes of memory.\n", | 162 | pr_info("PROM: Built device tree with %u bytes of memory.\n", |