Changeset 6a44ee4 in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-07-20T15:26:21Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
efcebe1
Parents:
25bef0ff (diff), a701812 (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

    r25bef0ff r6a44ee4  
    466466        fibril_mutex_lock(&drivers_list->drivers_mutex);
    467467       
    468         link_t *link = drivers_list->drivers.next;
    469         while (link != &drivers_list->drivers) {
     468        list_foreach(drivers_list->drivers, link) {
    470469                drv = list_get_instance(link, driver_t, drivers);
    471470                score = get_match_score(drv, node);
     
    474473                        best_drv = drv;
    475474                }
    476                 link = link->next;
    477475        }
    478476       
     
    536534        driver_t *res = NULL;
    537535        driver_t *drv = NULL;
    538         link_t *link;
    539536       
    540537        fibril_mutex_lock(&drv_list->drivers_mutex);
    541538       
    542         link = drv_list->drivers.next;
    543         while (link != &drv_list->drivers) {
     539        list_foreach(drv_list->drivers, link) {
    544540                drv = list_get_instance(link, driver_t, drivers);
    545541                if (str_cmp(drv->name, drv_name) == 0) {
     
    547543                        break;
    548544                }
    549 
    550                 link = link->next;
    551545        }
    552546       
     
    564558        dev_node_t *dev;
    565559        link_t *link;
    566         int phone;
    567560
    568561        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
     
    570563
    571564        fibril_mutex_lock(&driver->driver_mutex);
    572 
    573         phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
    574 
    575         if (phone < 0) {
     565       
     566        async_exch_t *exch = async_exchange_begin(driver->sess);
     567        async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     568            DRIVER_DEVMAN, 0, 0);
     569        async_exchange_end(exch);
     570
     571        if (!sess) {
    576572                fibril_mutex_unlock(&driver->driver_mutex);
    577573                return;
     
    582578         * that has not been passed to the driver.
    583579         */
    584         link = driver->devices.next;
    585         while (link != &driver->devices) {
     580        link = driver->devices.head.next;
     581        while (link != &driver->devices.head) {
    586582                dev = list_get_instance(link, dev_node_t, driver_devices);
    587583                if (dev->passed_to_driver) {
     
    602598                fibril_mutex_unlock(&driver->driver_mutex);
    603599
    604                 add_device(phone, driver, dev, tree);
     600                add_device(sess, driver, dev, tree);
    605601
    606602                /*
     
    620616                 * Restart the cycle to go through all devices again.
    621617                 */
    622                 link = driver->devices.next;
    623         }
    624 
    625         async_hangup(phone);
     618                link = driver->devices.head.next;
     619        }
     620
     621        async_hangup(sess);
    626622
    627623        /*
     
    673669        list_initialize(&drv->devices);
    674670        fibril_mutex_initialize(&drv->driver_mutex);
    675         drv->phone = -1;
     671        drv->sess = NULL;
    676672}
    677673
     
    737733 * @param node          The device's node in the device tree.
    738734 */
    739 void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
     735void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev,
     736    dev_tree_t *tree)
    740737{
    741738        /*
     
    746743            drv->name, dev->pfun->name);
    747744       
    748         sysarg_t rc;
    749         ipc_call_t answer;
    750        
    751745        /* Send the device to the driver. */
    752746        devman_handle_t parent_handle;
     
    756750                parent_handle = 0;
    757751        }
    758 
    759         aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
     752       
     753        async_exch_t *exch = async_exchange_begin(sess);
     754       
     755        ipc_call_t answer;
     756        aid_t req = async_send_2(exch, DRIVER_ADD_DEVICE, dev->handle,
    760757            parent_handle, &answer);
    761758       
    762         /* Send the device's name to the driver. */
    763         rc = async_data_write_start(phone, dev->pfun->name,
     759        /* Send the device name to the driver. */
     760        sysarg_t rc = async_data_write_start(exch, dev->pfun->name,
    764761            str_size(dev->pfun->name) + 1);
     762       
     763        async_exchange_end(exch);
     764       
    765765        if (rc != EOK) {
    766766                /* TODO handle error */
     
    823823        if (is_running) {
    824824                /* Notify the driver about the new device. */
    825                 int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
    826                 if (phone >= 0) {
    827                         add_device(phone, drv, dev, tree);
    828                         async_hangup(phone);
     825                async_exch_t *exch = async_exchange_begin(drv->sess);
     826                async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     827                    DRIVER_DEVMAN, 0, 0);
     828                async_exchange_end(exch);
     829               
     830                if (sess) {
     831                        add_device(sess, drv, dev, tree);
     832                        async_hangup(sess);
    829833                }
    830834        }
     
    11771181
    11781182        fun_node_t *fun;
    1179         link_t *link;
    1180 
    1181         for (link = dev->functions.next;
    1182             link != &dev->functions;
    1183             link = link->next) {
     1183
     1184        list_foreach(dev->functions, link) {
    11841185                fun = list_get_instance(link, fun_node_t, dev_functions);
    11851186
     
    13751376{
    13761377        dev_class_t *cl;
    1377         link_t *link = class_list->classes.next;
    1378        
    1379         while (link != &class_list->classes) {
     1378       
     1379        list_foreach(class_list->classes, link) {
    13801380                cl = list_get_instance(link, dev_class_t, link);
    13811381                if (str_cmp(cl->name, class_name) == 0) {
    13821382                        return cl;
    13831383                }
    1384                 link = link->next;
    13851384        }
    13861385       
     
    13981397        assert(dev_name != NULL);
    13991398
    1400         link_t *link;
    1401         for (link = dev_class->devices.next;
    1402             link != &dev_class->devices;
    1403             link = link->next) {
     1399        list_foreach(dev_class->devices, link) {
    14041400                dev_class_info_t *dev = list_get_instance(link,
    14051401                    dev_class_info_t, link);
Note: See TracChangeset for help on using the changeset viewer.