Changeset 965dc18 in mainline for kernel/genarch/src/ofw/ofw_tree.c
- Timestamp:
- 2008-12-05T19:59:03Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49093a4
- Parents:
- 0258e67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/ofw/ofw_tree.c
r0258e67 r965dc18 55 55 /** Get OpenFirmware node property. 56 56 * 57 * @param node Node in which to lookup the property. 58 * @param name Name of the property. 59 * 60 * @return Pointer to the property structure or NULL if no such property. 61 */ 62 ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name) 57 * @param node Node in which to lookup the property. 58 * @param name Name of the property. 59 * 60 * @return Pointer to the property structure or NULL if no such 61 * property. 62 */ 63 ofw_tree_property_t * 64 ofw_tree_getprop(const ofw_tree_node_t *node, const char *name) 63 65 { 64 66 unsigned int i; … … 74 76 /** Return value of the 'name' property. 75 77 * 76 * @param node 77 * 78 * @return 78 * @param node Node of interest. 79 * 80 * @return Value of the 'name' property belonging to the node. 79 81 */ 80 82 const char *ofw_tree_node_name(const ofw_tree_node_t *node) … … 94 96 /** Lookup child of given name. 95 97 * 96 * @param node Node whose child is being looked up. 97 * @param name Name of the child being looked up. 98 * 99 * @return NULL if there is no such child or pointer to the matching child node. 98 * @param node Node whose child is being looked up. 99 * @param name Name of the child being looked up. 100 * 101 * @return NULL if there is no such child or pointer to the 102 * matching child node. 100 103 */ 101 104 ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name) … … 128 131 /** Lookup first child of given device type. 129 132 * 130 * @param node Node whose child is being looked up. 131 * @param name Device type of the child being looked up. 132 * 133 * @return NULL if there is no such child or pointer to the matching child node. 134 */ 135 ofw_tree_node_t *ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name) 133 * @param node Node whose child is being looked up. 134 * @param name Device type of the child being looked up. 135 * 136 * @return NULL if there is no such child or pointer to the 137 * matching child node. 138 */ 139 ofw_tree_node_t * 140 ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name) 136 141 { 137 142 ofw_tree_node_t *cur; … … 154 159 * are looked up iteratively to avoid stack overflow. 155 160 * 156 * @param root Root of the searched subtree. 157 * @param handle OpenFirmware handle. 158 * 159 * @return NULL if there is no such node or pointer to the matching node. 160 */ 161 ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle) 161 * @param root Root of the searched subtree. 162 * @param handle OpenFirmware handle. 163 * 164 * @return NULL if there is no such node or pointer to the matching 165 * node. 166 */ 167 ofw_tree_node_t * 168 ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle) 162 169 { 163 170 ofw_tree_node_t *cur; … … 181 188 /** Lookup first peer of given device type. 182 189 * 183 * @param node Node whose peer is being looked up. 184 * @param name Device type of the child being looked up. 185 * 186 * @return NULL if there is no such child or pointer to the matching child node. 187 */ 188 ofw_tree_node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name) 190 * @param node Node whose peer is being looked up. 191 * @param name Device type of the child being looked up. 192 * 193 * @return NULL if there is no such child or pointer to the 194 * matching child node. 195 */ 196 ofw_tree_node_t * 197 ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name) 189 198 { 190 199 ofw_tree_node_t *cur; … … 203 212 204 213 214 /** Lookup first peer of given name. 215 * 216 * @param node Node whose peer is being looked up. 217 * @param name Name of the child being looked up. 218 * 219 * @return NULL if there is no such peer or pointer to the matching 220 * peer node. 221 */ 222 ofw_tree_node_t * 223 ofw_tree_find_peer_by_name(ofw_tree_node_t *node, const char *name) 224 { 225 ofw_tree_node_t *cur; 226 ofw_tree_property_t *prop; 227 228 for (cur = node->peer; cur; cur = cur->peer) { 229 prop = ofw_tree_getprop(cur, "name"); 230 if (!prop || !prop->value) 231 continue; 232 if (strcmp(prop->value, name) == 0) 233 return cur; 234 } 235 236 return NULL; 237 } 238 205 239 /** Lookup OpenFirmware node by its path. 206 240 * 207 * @param path Path to the node. 208 * 209 * @return NULL if there is no such node or pointer to the leaf node. 241 * @param path Path to the node. 242 * 243 * @return NULL if there is no such node or pointer to the leaf 244 * node. 210 245 */ 211 246 ofw_tree_node_t *ofw_tree_lookup(const char *path) 212 247 { 213 char buf[NAME_BUF_LEN +1];248 char buf[NAME_BUF_LEN + 1]; 214 249 ofw_tree_node_t *node = ofw_root; 215 250 index_t i, j; … … 237 272 * iteratively in order to avoid stack overflow. 238 273 * 239 * @param node 240 * @param path 274 * @param node Root of the subtree. 275 * @param path Current path, NULL for the very root of the entire tree. 241 276 */ 242 277 static void ofw_tree_node_print(const ofw_tree_node_t *node, const char *path)
Note:
See TracChangeset
for help on using the changeset viewer.