Changeset b72efe8 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2011-06-19T14:38:59Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74464e8
Parents:
1d1bb0f
Message:

Separate list_t typedef from link_t (user-space part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • assert_link_not_used()
  • usb_hid_report_path_free() shall not unlink the path, caller must do it
Location:
uspace/srv/devman
Files:
3 edited

Legend:

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

    r1d1bb0f rb72efe8  
    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       
     
    584578         * that has not been passed to the driver.
    585579         */
    586         link = driver->devices.next;
    587         while (link != &driver->devices) {
     580        link = driver->devices.head.next;
     581        while (link != &driver->devices.head) {
    588582                dev = list_get_instance(link, dev_node_t, driver_devices);
    589583                if (dev->passed_to_driver) {
     
    622616                 * Restart the cycle to go through all devices again.
    623617                 */
    624                 link = driver->devices.next;
     618                link = driver->devices.head.next;
    625619        }
    626620
     
    11871181
    11881182        fun_node_t *fun;
    1189         link_t *link;
    1190 
    1191         for (link = dev->functions.next;
    1192             link != &dev->functions;
    1193             link = link->next) {
     1183
     1184        list_foreach(dev->functions, link) {
    11941185                fun = list_get_instance(link, fun_node_t, dev_functions);
    11951186
     
    13851376{
    13861377        dev_class_t *cl;
    1387         link_t *link = class_list->classes.next;
    1388        
    1389         while (link != &class_list->classes) {
     1378       
     1379        list_foreach(class_list->classes, link) {
    13901380                cl = list_get_instance(link, dev_class_t, link);
    13911381                if (str_cmp(cl->name, class_name) == 0) {
    13921382                        return cl;
    13931383                }
    1394                 link = link->next;
    13951384        }
    13961385       
     
    14081397        assert(dev_name != NULL);
    14091398
    1410         link_t *link;
    1411         for (link = dev_class->devices.next;
    1412             link != &dev_class->devices;
    1413             link = link->next) {
     1399        list_foreach(dev_class->devices, link) {
    14141400                dev_class_info_t *dev = list_get_instance(link,
    14151401                    dev_class_info_t, link);
  • uspace/srv/devman/devman.h

    r1d1bb0f rb72efe8  
    9696        /** List of device ids for device-to-driver matching. */
    9797        match_id_list_t match_ids;
    98         /** Pointer to the linked list of devices controlled by this driver. */
    99         link_t devices;
     98        /** List of devices controlled by this driver. */
     99        list_t devices;
    100100       
    101101        /**
     
    108108typedef struct driver_list {
    109109        /** List of drivers */
    110         link_t drivers;
     110        list_t drivers;
    111111        /** Fibril mutex for list of drivers. */
    112112        fibril_mutex_t drivers_mutex;
     
    130130       
    131131        /** List of device functions. */
    132         link_t functions;
     132        list_t functions;
    133133        /** Driver of this device. */
    134134        driver_t *drv;
     
    170170        match_id_list_t match_ids;
    171171       
    172         /** The list of device classes to which this device function belongs. */
    173         link_t classes;
     172        /** List of device classes to which this device function belongs. */
     173        list_t classes;
    174174        /** Devmap handle if the device function is registered by devmap. */
    175175        devmap_handle_t devmap_handle;
     
    228228         * this class.
    229229         */
    230         link_t devices;
     230        list_t devices;
    231231       
    232232        /**
     
    280280typedef struct class_list {
    281281        /** List of classes. */
    282         link_t classes;
     282        list_t classes;
    283283       
    284284        /**
  • uspace/srv/devman/match.c

    r1d1bb0f rb72efe8  
    5959int get_match_score(driver_t *drv, dev_node_t *dev)
    6060{
    61         link_t *drv_head = &drv->match_ids.ids;
    62         link_t *dev_head = &dev->pfun->match_ids.ids;
     61        link_t *drv_head = &drv->match_ids.ids.head;
     62        link_t *dev_head = &dev->pfun->match_ids.ids.head;
    6363       
    64         if (list_empty(drv_head) || list_empty(dev_head))
     64        if (list_empty(&drv->match_ids.ids) ||
     65            list_empty(&dev->pfun->match_ids.ids)) {
    6566                return 0;
     67        }
    6668       
    6769        /*
     
    7072        int highest_score = 0;
    7173       
    72         link_t *drv_link = drv->match_ids.ids.next;
     74        link_t *drv_link = drv->match_ids.ids.head.next;
    7375        while (drv_link != drv_head) {
    7476                link_t *dev_link = dev_head->next;
Note: See TracChangeset for help on using the changeset viewer.