Changeset 2f8f480 in mainline for kernel/genarch/src/ofw/ofw_tree.c
- Timestamp:
- 2006-11-07T18:41:42Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3869e9c5
- Parents:
- b63a7cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/ofw/ofw_tree.c
rb63a7cc r2f8f480 151 151 /** Lookup node with matching node_handle. 152 152 * 153 * Child nodes are looked up recursively contrary to peer nodes that 154 * are looked up iteratively to avoid stack overflow. 155 * 153 156 * @param root Root of the searched subtree. 154 157 * @param handle OpenFirmware handle. … … 158 161 ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle) 159 162 { 160 ofw_tree_node_t *node; 161 162 if (root->node_handle == handle) 163 return root; 164 165 if (root->peer) { 166 node = ofw_tree_find_node_by_handle(root->peer, handle); 167 if (node) 168 return node; 169 } 170 171 if (root->child) { 172 node = ofw_tree_find_node_by_handle(root->child, handle); 173 if (node) 174 return node; 163 ofw_tree_node_t *cur; 164 165 for (cur = root; cur; cur = cur->peer) { 166 if (cur->node_handle == handle) 167 return cur; 168 169 if (cur->child) { 170 ofw_tree_node_t *node; 171 172 node = ofw_tree_find_node_by_handle(cur->child, handle); 173 if (node) 174 return node; 175 } 175 176 } 176 177 … … 231 232 } 232 233 233 /** Recursively print subtree rooted in a node. 234 /** Print OpenFirmware device subtree rooted in a node. 235 * 236 * Child nodes are processed recursively and peer nodes are processed 237 * iteratively in order to avoid stack overflow. 234 238 * 235 239 * @param node Root of the subtree. … … 239 243 { 240 244 char *p; 245 const ofw_tree_node_t *cur; 241 246 242 247 p = (char *) malloc(PATH_MAX_LEN, 0); 243 248 244 if (node->parent) { 245 snprintf(p, PATH_MAX_LEN, "%s/%s", path, node->da_name); 246 printf("%s\n", p); 247 } else { 248 snprintf(p, PATH_MAX_LEN, "%s", node->da_name); 249 printf("/\n"); 250 } 251 252 if (node->child) 253 ofw_tree_node_print(node->child, p); 254 255 if (node->peer) 256 ofw_tree_node_print(node->peer, path); 249 for (cur = node; cur; cur = cur->peer) { 250 if (cur->parent) { 251 snprintf(p, PATH_MAX_LEN, "%s/%s", path, cur->da_name); 252 printf("%s\n", p); 253 } else { 254 snprintf(p, PATH_MAX_LEN, "%s", cur->da_name); 255 printf("/\n"); 256 } 257 258 if (cur->child) 259 ofw_tree_node_print(cur->child, p); 260 } 257 261 258 262 free(p);
Note:
See TracChangeset
for help on using the changeset viewer.