aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/prom/tree_32.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/prom/tree_32.c')
-rw-r--r--arch/sparc/prom/tree_32.c67
1 files changed, 16 insertions, 51 deletions
diff --git a/arch/sparc/prom/tree_32.c b/arch/sparc/prom/tree_32.c
index 535e2e69ac1d..f30e8d038f01 100644
--- a/arch/sparc/prom/tree_32.c
+++ b/arch/sparc/prom/tree_32.c
@@ -20,7 +20,7 @@ extern void restore_current(void);
20static char promlib_buf[128]; 20static char promlib_buf[128];
21 21
22/* Internal version of prom_getchild that does not alter return values. */ 22/* Internal version of prom_getchild that does not alter return values. */
23phandle __prom_getchild(phandle node) 23static phandle __prom_getchild(phandle node)
24{ 24{
25 unsigned long flags; 25 unsigned long flags;
26 phandle cnode; 26 phandle cnode;
@@ -40,11 +40,11 @@ phandle prom_getchild(phandle node)
40{ 40{
41 phandle cnode; 41 phandle cnode;
42 42
43 if (node == -1) 43 if ((s32)node == -1)
44 return 0; 44 return 0;
45 45
46 cnode = __prom_getchild(node); 46 cnode = __prom_getchild(node);
47 if (cnode == 0 || cnode == -1) 47 if (cnode == 0 || (s32)cnode == -1)
48 return 0; 48 return 0;
49 49
50 return cnode; 50 return cnode;
@@ -52,7 +52,7 @@ phandle prom_getchild(phandle node)
52EXPORT_SYMBOL(prom_getchild); 52EXPORT_SYMBOL(prom_getchild);
53 53
54/* Internal version of prom_getsibling that does not alter return values. */ 54/* Internal version of prom_getsibling that does not alter return values. */
55phandle __prom_getsibling(phandle node) 55static phandle __prom_getsibling(phandle node)
56{ 56{
57 unsigned long flags; 57 unsigned long flags;
58 phandle cnode; 58 phandle cnode;
@@ -72,11 +72,11 @@ phandle prom_getsibling(phandle node)
72{ 72{
73 phandle sibnode; 73 phandle sibnode;
74 74
75 if (node == -1) 75 if ((s32)node == -1)
76 return 0; 76 return 0;
77 77
78 sibnode = __prom_getsibling(node); 78 sibnode = __prom_getsibling(node);
79 if (sibnode == 0 || sibnode == -1) 79 if (sibnode == 0 || (s32)sibnode == -1)
80 return 0; 80 return 0;
81 81
82 return sibnode; 82 return sibnode;
@@ -177,20 +177,6 @@ void prom_getstring(phandle node, char *prop, char *user_buf, int ubuf_size)
177EXPORT_SYMBOL(prom_getstring); 177EXPORT_SYMBOL(prom_getstring);
178 178
179 179
180/* Does the device at node 'node' have name 'name'?
181 * YES = 1 NO = 0
182 */
183int prom_nodematch(phandle node, char *name)
184{
185 int error;
186
187 static char namebuf[128];
188 error = prom_getproperty(node, "name", namebuf, sizeof(namebuf));
189 if (error == -1) return 0;
190 if(strcmp(namebuf, name) == 0) return 1;
191 return 0;
192}
193
194/* Search siblings at 'node_start' for a node with name 180/* Search siblings at 'node_start' for a node with name
195 * 'nodename'. Return node if successful, zero if not. 181 * 'nodename'. Return node if successful, zero if not.
196 */ 182 */
@@ -214,7 +200,7 @@ phandle prom_searchsiblings(phandle node_start, char *nodename)
214EXPORT_SYMBOL(prom_searchsiblings); 200EXPORT_SYMBOL(prom_searchsiblings);
215 201
216/* Interal version of nextprop that does not alter return values. */ 202/* Interal version of nextprop that does not alter return values. */
217char *__prom_nextprop(phandle node, char * oprop) 203static char *__prom_nextprop(phandle node, char * oprop)
218{ 204{
219 unsigned long flags; 205 unsigned long flags;
220 char *prop; 206 char *prop;
@@ -227,24 +213,13 @@ char *__prom_nextprop(phandle node, char * oprop)
227 return prop; 213 return prop;
228} 214}
229 215
230/* Return the first property name for node 'node'. */
231/* buffer is unused argument, but as v9 uses it, we need to have the same interface */
232char *prom_firstprop(phandle node, char *bufer)
233{
234 if (node == 0 || node == -1)
235 return "";
236
237 return __prom_nextprop(node, "");
238}
239EXPORT_SYMBOL(prom_firstprop);
240
241/* Return the property type string after property type 'oprop' 216/* Return the property type string after property type 'oprop'
242 * at node 'node' . Returns empty string if no more 217 * at node 'node' . Returns empty string if no more
243 * property types for this node. 218 * property types for this node.
244 */ 219 */
245char *prom_nextprop(phandle node, char *oprop, char *buffer) 220char *prom_nextprop(phandle node, char *oprop, char *buffer)
246{ 221{
247 if (node == 0 || node == -1) 222 if (node == 0 || (s32)node == -1)
248 return ""; 223 return "";
249 224
250 return __prom_nextprop(node, oprop); 225 return __prom_nextprop(node, oprop);
@@ -278,7 +253,7 @@ phandle prom_finddevice(char *name)
278 if (d != s + 3 && (!*d || *d == '/') 253 if (d != s + 3 && (!*d || *d == '/')
279 && d <= s + 3 + 8) { 254 && d <= s + 3 + 8) {
280 node2 = node; 255 node2 = node;
281 while (node2 && node2 != -1) { 256 while (node2 && (s32)node2 != -1) {
282 if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) { 257 if (prom_getproperty (node2, "reg", (char *)reg, sizeof (reg)) > 0) {
283 if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) { 258 if (which_io == reg[0].which_io && phys_addr == reg[0].phys_addr) {
284 node = node2; 259 node = node2;
@@ -286,7 +261,7 @@ phandle prom_finddevice(char *name)
286 } 261 }
287 } 262 }
288 node2 = prom_getsibling(node2); 263 node2 = prom_getsibling(node2);
289 if (!node2 || node2 == -1) 264 if (!node2 || (s32)node2 == -1)
290 break; 265 break;
291 node2 = prom_searchsiblings(prom_getsibling(node2), nbuf); 266 node2 = prom_searchsiblings(prom_getsibling(node2), nbuf);
292 } 267 }
@@ -299,19 +274,6 @@ phandle prom_finddevice(char *name)
299} 274}
300EXPORT_SYMBOL(prom_finddevice); 275EXPORT_SYMBOL(prom_finddevice);
301 276
302int prom_node_has_property(phandle node, char *prop)
303{
304 char *current_property = "";
305
306 do {
307 current_property = prom_nextprop(node, current_property, NULL);
308 if(!strcmp(current_property, prop))
309 return 1;
310 } while (*current_property);
311 return 0;
312}
313EXPORT_SYMBOL(prom_node_has_property);
314
315/* Set property 'pname' at node 'node' to value 'value' which has a length 277/* Set property 'pname' at node 'node' to value 'value' which has a length
316 * of 'size' bytes. Return the number of bytes the prom accepted. 278 * of 'size' bytes. Return the number of bytes the prom accepted.
317 */ 279 */
@@ -320,8 +282,10 @@ int prom_setprop(phandle node, const char *pname, char *value, int size)
320 unsigned long flags; 282 unsigned long flags;
321 int ret; 283 int ret;
322 284
323 if(size == 0) return 0; 285 if (size == 0)
324 if((pname == 0) || (value == 0)) return 0; 286 return 0;
287 if ((pname == NULL) || (value == NULL))
288 return 0;
325 spin_lock_irqsave(&prom_lock, flags); 289 spin_lock_irqsave(&prom_lock, flags);
326 ret = prom_nodeops->no_setprop(node, pname, value, size); 290 ret = prom_nodeops->no_setprop(node, pname, value, size);
327 restore_current(); 291 restore_current();
@@ -339,6 +303,7 @@ phandle prom_inst2pkg(int inst)
339 node = (*romvec->pv_v2devops.v2_inst2pkg)(inst); 303 node = (*romvec->pv_v2devops.v2_inst2pkg)(inst);
340 restore_current(); 304 restore_current();
341 spin_unlock_irqrestore(&prom_lock, flags); 305 spin_unlock_irqrestore(&prom_lock, flags);
342 if (node == -1) return 0; 306 if ((s32)node == -1)
307 return 0;
343 return node; 308 return node;
344} 309}