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


Ignore:
Timestamp:
2011-08-03T17:34:57Z (15 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1940326
Parents:
52a79081 (diff), 3fab770 (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 from mainline

File:
1 edited

Legend:

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

    r52a79081 ra33f0a6  
    270270        }
    271271       
    272         ssize_t read_bytes = safe_read(fd, buf, len);
     272        ssize_t read_bytes = read_all(fd, buf, len);
    273273        if (read_bytes <= 0) {
    274                 log_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
     274                log_msg(LVL_ERROR, "Unable to read file '%s' (%zd).", conf_path,
     275                    read_bytes);
    275276                goto cleanup;
    276277        }
     
    421422        }
    422423       
    423         insert_fun_node(tree, fun, clone_string(""), NULL);
     424        insert_fun_node(tree, fun, str_dup(""), NULL);
    424425        match_id_t *id = create_match_id();
    425         id->id = clone_string("root");
     426        id->id = str_dup("root");
    426427        id->score = 100;
    427428        add_match_id(&fun->match_ids, id);
     
    466467        fibril_mutex_lock(&drivers_list->drivers_mutex);
    467468       
    468         link_t *link = drivers_list->drivers.next;
    469         while (link != &drivers_list->drivers) {
     469        list_foreach(drivers_list->drivers, link) {
    470470                drv = list_get_instance(link, driver_t, drivers);
    471471                score = get_match_score(drv, node);
     
    474474                        best_drv = drv;
    475475                }
    476                 link = link->next;
    477476        }
    478477       
     
    536535        driver_t *res = NULL;
    537536        driver_t *drv = NULL;
    538         link_t *link;
    539537       
    540538        fibril_mutex_lock(&drv_list->drivers_mutex);
    541539       
    542         link = drv_list->drivers.next;
    543         while (link != &drv_list->drivers) {
     540        list_foreach(drv_list->drivers, link) {
    544541                drv = list_get_instance(link, driver_t, drivers);
    545542                if (str_cmp(drv->name, drv_name) == 0) {
     
    547544                        break;
    548545                }
    549 
    550                 link = link->next;
    551546        }
    552547       
     
    564559        dev_node_t *dev;
    565560        link_t *link;
    566         int phone;
    567561
    568562        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
     
    570564
    571565        fibril_mutex_lock(&driver->driver_mutex);
    572 
    573         phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
    574 
    575         if (phone < 0) {
     566       
     567        async_exch_t *exch = async_exchange_begin(driver->sess);
     568        async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     569            DRIVER_DEVMAN, 0, 0);
     570        async_exchange_end(exch);
     571
     572        if (!sess) {
    576573                fibril_mutex_unlock(&driver->driver_mutex);
    577574                return;
     
    582579         * that has not been passed to the driver.
    583580         */
    584         link = driver->devices.next;
    585         while (link != &driver->devices) {
     581        link = driver->devices.head.next;
     582        while (link != &driver->devices.head) {
    586583                dev = list_get_instance(link, dev_node_t, driver_devices);
    587584                if (dev->passed_to_driver) {
     
    602599                fibril_mutex_unlock(&driver->driver_mutex);
    603600
    604                 add_device(phone, driver, dev, tree);
     601                add_device(sess, driver, dev, tree);
    605602
    606603                /*
     
    620617                 * Restart the cycle to go through all devices again.
    621618                 */
    622                 link = driver->devices.next;
    623         }
    624 
    625         async_hangup(phone);
     619                link = driver->devices.head.next;
     620        }
     621
     622        async_hangup(sess);
    626623
    627624        /*
     
    673670        list_initialize(&drv->devices);
    674671        fibril_mutex_initialize(&drv->driver_mutex);
    675         drv->phone = -1;
     672        drv->sess = NULL;
    676673}
    677674
     
    737734 * @param node          The device's node in the device tree.
    738735 */
    739 void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
     736void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev,
     737    dev_tree_t *tree)
    740738{
    741739        /*
     
    746744            drv->name, dev->pfun->name);
    747745       
    748         sysarg_t rc;
    749         ipc_call_t answer;
    750        
    751746        /* Send the device to the driver. */
    752747        devman_handle_t parent_handle;
     
    756751                parent_handle = 0;
    757752        }
    758 
    759         aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
     753       
     754        async_exch_t *exch = async_exchange_begin(sess);
     755       
     756        ipc_call_t answer;
     757        aid_t req = async_send_2(exch, DRIVER_ADD_DEVICE, dev->handle,
    760758            parent_handle, &answer);
    761759       
    762         /* Send the device's name to the driver. */
    763         rc = async_data_write_start(phone, dev->pfun->name,
     760        /* Send the device name to the driver. */
     761        sysarg_t rc = async_data_write_start(exch, dev->pfun->name,
    764762            str_size(dev->pfun->name) + 1);
     763       
     764        async_exchange_end(exch);
     765       
    765766        if (rc != EOK) {
    766767                /* TODO handle error */
     
    823824        if (is_running) {
    824825                /* 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);
     826                async_exch_t *exch = async_exchange_begin(drv->sess);
     827                async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     828                    DRIVER_DEVMAN, 0, 0);
     829                async_exchange_end(exch);
     830               
     831                if (sess) {
     832                        add_device(sess, drv, dev, tree);
     833                        async_hangup(sess);
    829834                }
    830835        }
     
    11771182
    11781183        fun_node_t *fun;
    1179         link_t *link;
    1180 
    1181         for (link = dev->functions.next;
    1182             link != &dev->functions;
    1183             link = link->next) {
     1184
     1185        list_foreach(dev->functions, link) {
    11841186                fun = list_get_instance(link, fun_node_t, dev_functions);
    11851187
     
    13751377{
    13761378        dev_class_t *cl;
    1377         link_t *link = class_list->classes.next;
    1378        
    1379         while (link != &class_list->classes) {
     1379       
     1380        list_foreach(class_list->classes, link) {
    13801381                cl = list_get_instance(link, dev_class_t, link);
    13811382                if (str_cmp(cl->name, class_name) == 0) {
    13821383                        return cl;
    13831384                }
    1384                 link = link->next;
    13851385        }
    13861386       
     
    13981398        assert(dev_name != NULL);
    13991399
    1400         link_t *link;
    1401         for (link = dev_class->devices.next;
    1402             link != &dev_class->devices;
    1403             link = link->next) {
     1400        list_foreach(dev_class->devices, link) {
    14041401                dev_class_info_t *dev = list_get_instance(link,
    14051402                    dev_class_info_t, link);
Note: See TracChangeset for help on using the changeset viewer.