Changeset 7beb220 in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-08-19T12:06:03Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2f2f1186
Parents:
d767cb1
Message:

Skeleton of devctl utility. Currently prints device tree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    rd767cb1 r7beb220  
    920920}
    921921
     922/** Get list of device functions. */
     923int dev_get_functions(dev_tree_t *tree, dev_node_t *dev,
     924    devman_handle_t *hdl_buf, size_t buf_size, size_t *act_size)
     925{
     926        size_t act_cnt;
     927        size_t buf_cnt;
     928
     929        assert(fibril_rwlock_is_locked(&tree->rwlock));
     930
     931        buf_cnt = buf_size / sizeof(devman_handle_t);
     932
     933        act_cnt = list_count(&dev->functions);
     934        *act_size = act_cnt * sizeof(devman_handle_t);
     935
     936        if (buf_size % sizeof(devman_handle_t) != 0)
     937                return EINVAL;
     938
     939        size_t pos = 0;
     940        list_foreach(dev->functions, item) {
     941                fun_node_t *fun =
     942                    list_get_instance(item, fun_node_t, dev_functions);
     943
     944                if (pos < buf_cnt)
     945                        hdl_buf[pos] = fun->handle;
     946                pos++;
     947        }
     948
     949        return EOK;
     950}
     951
     952
    922953/* Function nodes */
    923954
     
    11451176        char *rel_path = path;
    11461177        char *next_path_elem = NULL;
    1147         bool cont = true;
     1178        bool cont = (rel_path[1] != '\0');
    11481179       
    11491180        while (cont && fun != NULL) {
Note: See TracChangeset for help on using the changeset viewer.