Ignore:
File:
1 edited

Legend:

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

    rb72efe8 rc7bbf029  
    466466        fibril_mutex_lock(&drivers_list->drivers_mutex);
    467467       
    468         list_foreach(drivers_list->drivers, link) {
     468        link_t *link = drivers_list->drivers.next;
     469        while (link != &drivers_list->drivers) {
    469470                drv = list_get_instance(link, driver_t, drivers);
    470471                score = get_match_score(drv, node);
     
    473474                        best_drv = drv;
    474475                }
     476                link = link->next;
    475477        }
    476478       
     
    534536        driver_t *res = NULL;
    535537        driver_t *drv = NULL;
     538        link_t *link;
    536539       
    537540        fibril_mutex_lock(&drv_list->drivers_mutex);
    538541       
    539         list_foreach(drv_list->drivers, link) {
     542        link = drv_list->drivers.next;
     543        while (link != &drv_list->drivers) {
    540544                drv = list_get_instance(link, driver_t, drivers);
    541545                if (str_cmp(drv->name, drv_name) == 0) {
     
    543547                        break;
    544548                }
     549
     550                link = link->next;
    545551        }
    546552       
     
    558564        dev_node_t *dev;
    559565        link_t *link;
     566        int phone;
    560567
    561568        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
     
    563570
    564571        fibril_mutex_lock(&driver->driver_mutex);
    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) {
     572
     573        phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
     574
     575        if (phone < 0) {
    572576                fibril_mutex_unlock(&driver->driver_mutex);
    573577                return;
     
    578582         * that has not been passed to the driver.
    579583         */
    580         link = driver->devices.head.next;
    581         while (link != &driver->devices.head) {
     584        link = driver->devices.next;
     585        while (link != &driver->devices) {
    582586                dev = list_get_instance(link, dev_node_t, driver_devices);
    583587                if (dev->passed_to_driver) {
     
    598602                fibril_mutex_unlock(&driver->driver_mutex);
    599603
    600                 add_device(sess, driver, dev, tree);
     604                add_device(phone, driver, dev, tree);
    601605
    602606                /*
     
    616620                 * Restart the cycle to go through all devices again.
    617621                 */
    618                 link = driver->devices.head.next;
    619         }
    620 
    621         async_hangup(sess);
     622                link = driver->devices.next;
     623        }
     624
     625        async_hangup(phone);
    622626
    623627        /*
     
    669673        list_initialize(&drv->devices);
    670674        fibril_mutex_initialize(&drv->driver_mutex);
    671         drv->sess = NULL;
     675        drv->phone = -1;
    672676}
    673677
     
    733737 * @param node          The device's node in the device tree.
    734738 */
    735 void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev,
    736     dev_tree_t *tree)
     739void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
    737740{
    738741        /*
     
    743746            drv->name, dev->pfun->name);
    744747       
     748        sysarg_t rc;
     749        ipc_call_t answer;
     750       
    745751        /* Send the device to the driver. */
    746752        devman_handle_t parent_handle;
     
    750756                parent_handle = 0;
    751757        }
    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,
     758
     759        aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
    757760            parent_handle, &answer);
    758761       
    759         /* Send the device name to the driver. */
    760         sysarg_t rc = async_data_write_start(exch, dev->pfun->name,
     762        /* Send the device's name to the driver. */
     763        rc = async_data_write_start(phone, dev->pfun->name,
    761764            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                 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);
     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);
    833829                }
    834830        }
     
    11811177
    11821178        fun_node_t *fun;
    1183 
    1184         list_foreach(dev->functions, link) {
     1179        link_t *link;
     1180
     1181        for (link = dev->functions.next;
     1182            link != &dev->functions;
     1183            link = link->next) {
    11851184                fun = list_get_instance(link, fun_node_t, dev_functions);
    11861185
     
    13761375{
    13771376        dev_class_t *cl;
    1378        
    1379         list_foreach(class_list->classes, link) {
     1377        link_t *link = class_list->classes.next;
     1378       
     1379        while (link != &class_list->classes) {
    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;
    13841385        }
    13851386       
     
    13971398        assert(dev_name != NULL);
    13981399
    1399         list_foreach(dev_class->devices, link) {
     1400        link_t *link;
     1401        for (link = dev_class->devices.next;
     1402            link != &dev_class->devices;
     1403            link = link->next) {
    14001404                dev_class_info_t *dev = list_get_instance(link,
    14011405                    dev_class_info_t, link);
Note: See TracChangeset for help on using the changeset viewer.