Changeset 5cd136ab in mainline for uspace/srv/devman/devman.c
- Timestamp:
- 2010-04-02T13:37:58Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a66bc2e
- Parents:
- 57937dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r57937dd r5cd136ab 506 506 if (rc != EOK) { 507 507 // TODO handle error 508 return false;508 return; 509 509 } 510 510 511 511 // TODO inspect return value (ret) to find out whether the device was successfully probed and added 512 512 513 return true;513 return; 514 514 } 515 515 … … 618 618 * @return true on success, false otherwise (insufficient resources etc.). 619 619 */ 620 bool insert_dev_node(dev_tree_t *tree, node_t *node, c onst char *dev_name, node_t *parent)620 bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name, node_t *parent) 621 621 { 622 622 printf(NAME ": insert_dev_node\n"); … … 650 650 } 651 651 652 /** 653 * Find device node with a specified path in the device tree. 654 * 655 * @param path the path of the device node in the device tree. 656 * @param tree the device tree. 657 * 658 * @return the device node if it is present in the tree, NULL otherwise. 659 */ 660 node_t * find_dev_node_by_path(dev_tree_t *tree, char *path) 661 { 662 node_t *dev = tree->root_node; 663 char *rel_path = path; 664 char *next_path_elem = NULL; 665 size_t elem_size = 0; 666 bool cont = '/' == rel_path[0]; 667 668 while (cont && NULL != dev) { 669 next_path_elem = get_path_elem_end(rel_path+1); 670 if ('/' == next_path_elem[0]) { 671 cont = true; 672 next_path_elem[0] = 0; 673 } else { 674 cont = false; 675 } 676 677 dev = find_node_child(dev, rel_path); 678 679 if (cont) { 680 next_path_elem[0] = '/'; 681 } 682 rel_path = next_path_elem; 683 } 684 685 return dev; 686 } 687 688 /** 689 * Find child device node with a specified name. 690 * 691 * @param parent the parent device node. 692 * @param name the name of the child device node. 693 * 694 * @return the child device node. 695 */ 696 node_t *find_node_child(node_t *parent, const char *name) 697 { 698 node_t *dev; 699 link_t *link; 700 701 fibril_mutex_lock(&parent->children_mutex); 702 link = parent->children.next; 703 704 while (link != &parent->children) { 705 dev = list_get_instance(link, node_t, sibling); 706 707 if (0 == str_cmp(name, dev->name)) { 708 fibril_mutex_unlock(&parent->children_mutex); 709 return dev; 710 } 711 } 712 713 fibril_mutex_unlock(&parent->children_mutex); 714 return NULL; 715 } 716 652 717 /** @} 653 718 */
Note:
See TracChangeset
for help on using the changeset viewer.