// SPDX-License-Identifier: GPL-2.0 /* * tree.c: Basic device tree traversal/scanning for the Linux * prom library. * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
*/
/* Return the child of node 'node' or zero if no this node has no * direct descendent.
*/ inline phandle __prom_getchild(phandle node)
{ return prom_node_to_node("child", node);
}
if ((s32)node == -1) return 0;
cnode = prom_node_to_node("parent", node); if ((s32)cnode == -1) return 0; return cnode;
}
/* Return the next sibling of node 'node' or zero if no more siblings * at this level of depth in the tree.
*/ inline phandle __prom_getsibling(phandle node)
{ return prom_node_to_node(prom_peer_name, node);
}
if ((s32)node == -1) return 0;
sibnode = __prom_getsibling(node); if ((s32)sibnode == -1) return 0;
return sibnode;
}
EXPORT_SYMBOL(prom_getsibling);
/* Return the length in bytes of property 'prop' at node 'node'. * Return -1 on error.
*/ int prom_getproplen(phandle node, constchar *prop)
{ unsignedlong args[6];
/* Acquire a property 'prop' at node 'node' and place it in * 'buffer' which has a size of 'bufsize'. If the acquisition * was successful the length will be returned, else -1 is returned.
*/ int prom_getproperty(phandle node, constchar *prop, char *buffer, int bufsize)
{ unsignedlong args[8]; int plen;
/* Acquire a property whose value is a string, returns a null * string on error. The char pointer is the user supplied string * buffer.
*/ void prom_getstring(phandle node, constchar *prop, char *user_buf, int ubuf_size)
{ int len;
len = prom_getproperty(node, prop, user_buf, ubuf_size); if (len != -1) return;
user_buf[0] = 0;
}
EXPORT_SYMBOL(prom_getstring);
/* Does the device at node 'node' have name 'name'? * YES = 1 NO = 0
*/ int prom_nodematch(phandle node, constchar *name)
{ char namebuf[128];
prom_getproperty(node, "name", namebuf, sizeof(namebuf)); if (strcmp(namebuf, name) == 0) return 1; return 0;
}
/* Search siblings at 'node_start' for a node with name * 'nodename'. Return node if successful, zero if not.
*/
phandle prom_searchsiblings(phandle node_start, constchar *nodename)
{
phandle thisnode; int error; char promlib_buf[128];
/* Return the first property type for node 'node'. * buffer should be at least 32B in length
*/ char *prom_firstprop(phandle node, char *buffer)
{ unsignedlong args[7];
/* Return the property type string after property type 'oprop' * at node 'node' . Returns NULL string if no more * property types for this node.
*/ char *prom_nextprop(phandle node, constchar *oprop, char *buffer)
{ unsignedlong args[7]; char buf[32];
int prom_node_has_property(phandle node, constchar *prop)
{ char buf [32];
*buf = 0; do {
prom_nextprop(node, buf, buf); if (!strcmp(buf, prop)) return 1;
} while (*buf); return 0;
}
EXPORT_SYMBOL(prom_node_has_property);
/* Set property 'pname' at node 'node' to value 'value' which has a length * of 'size' bytes. Return the number of bytes the prom accepted.
*/ int
prom_setprop(phandle node, constchar *pname, char *value, int size)
{ unsignedlong args[8];
if (size == 0) return 0; if ((pname == NULL) || (value == NULL)) return 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.