Changeset d1e196f7 in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-08-21T12:04:27Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8a6ba94
Parents:
1877128 (diff), a6480d5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r1877128 rd1e196f7  
    548548
    549549        fibril_mutex_lock(&driver->driver_mutex);
    550        
    551         async_exch_t *exch = async_exchange_begin(driver->sess);
    552         async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
    553             DRIVER_DEVMAN, 0, 0);
    554         async_exchange_end(exch);
    555 
    556         if (!sess) {
    557                 fibril_mutex_unlock(&driver->driver_mutex);
    558                 return;
    559         }
    560550
    561551        /*
     
    583573                fibril_mutex_unlock(&driver->driver_mutex);
    584574
    585                 add_device(sess, driver, dev, tree);
     575                add_device(driver, dev, tree);
    586576
    587577                /*
     
    603593                link = driver->devices.head.next;
    604594        }
    605 
    606         async_hangup(sess);
    607595
    608596        /*
     
    718706 * @param node          The device's node in the device tree.
    719707 */
    720 void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev,
    721     dev_tree_t *tree)
     708void add_device(driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
    722709{
    723710        /*
     
    736723        }
    737724       
    738         async_exch_t *exch = async_exchange_begin(sess);
     725        async_exch_t *exch = async_exchange_begin(drv->sess);
    739726       
    740727        ipc_call_t answer;
     
    806793        fibril_mutex_unlock(&drv->driver_mutex);
    807794
    808         if (is_running) {
    809                 /* Notify the driver about the new device. */
    810                 async_exch_t *exch = async_exchange_begin(drv->sess);
    811                 async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
    812                     DRIVER_DEVMAN, 0, 0);
    813                 async_exchange_end(exch);
    814                
    815                 if (sess) {
    816                         add_device(sess, drv, dev, tree);
    817                         async_hangup(sess);
    818                 }
    819         }
     795        /* Notify the driver about the new device. */
     796        if (is_running)
     797                add_device(drv, dev, tree);
    820798       
    821799        return true;
     
    919897        return dev;
    920898}
     899
     900/** Get list of device functions. */
     901int dev_get_functions(dev_tree_t *tree, dev_node_t *dev,
     902    devman_handle_t *hdl_buf, size_t buf_size, size_t *act_size)
     903{
     904        size_t act_cnt;
     905        size_t buf_cnt;
     906
     907        assert(fibril_rwlock_is_locked(&tree->rwlock));
     908
     909        buf_cnt = buf_size / sizeof(devman_handle_t);
     910
     911        act_cnt = list_count(&dev->functions);
     912        *act_size = act_cnt * sizeof(devman_handle_t);
     913
     914        if (buf_size % sizeof(devman_handle_t) != 0)
     915                return EINVAL;
     916
     917        size_t pos = 0;
     918        list_foreach(dev->functions, item) {
     919                fun_node_t *fun =
     920                    list_get_instance(item, fun_node_t, dev_functions);
     921
     922                if (pos < buf_cnt)
     923                        hdl_buf[pos] = fun->handle;
     924                pos++;
     925        }
     926
     927        return EOK;
     928}
     929
    921930
    922931/* Function nodes */
     
    11451154        char *rel_path = path;
    11461155        char *next_path_elem = NULL;
    1147         bool cont = true;
     1156        bool cont = (rel_path[1] != '\0');
    11481157       
    11491158        while (cont && fun != NULL) {
Note: See TracChangeset for help on using the changeset viewer.