Changeset 692c40cb in mainline for uspace/srv/devman/devman.h


Ignore:
Timestamp:
2010-05-28T09:04:37Z (15 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5159ae9
Parents:
c9f3b45c
Message:

Introduce device classes.Device class specifies functional type of the device. Device classes are identified by their string names (actually device class is just a string value). Device classes can be dynamically added. A device can be added to any number of classes.

File:
1 edited

Legend:

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

    rc9f3b45c r692c40cb  
    158158        link_t link;   
    159159        /** List of dev_class_info structures - one for each device registered by this class.*/
    160         link_t devices; 
    161         /** Default base name for the device within the class, might be overrided by the driver.*/
     160        link_t devices;
     161        /** Default base name for the device within the class, might be overrided by the driver.*/     
    162162        const char *base_dev_name;
    163         /** Unique numerical identifier appened to the base name of the newly added device.*/
     163        /** Unique numerical identifier of the newly added device.*/
    164164        size_t curr_dev_idx;
    165165        /** Synchronize access to the list of devices in this class. */
     
    185185} dev_class_info_t;
    186186
     187/** The list of device classes. */
     188typedef struct class_list {
     189        /** List of classes */
     190        link_t classes;
     191        /** Fibril mutex for list of classes. */
     192        fibril_mutex_t classes_mutex;   
     193} class_list_t;
     194
    187195// Match ids and scores
    188196
     
    282290{
    283291        node_t *res = malloc(sizeof(node_t));
     292       
    284293        if (res != NULL) {
    285294                memset(res, 0, sizeof(node_t));
     295                list_initialize(&res->children);
     296                list_initialize(&res->match_ids.ids);
     297                list_initialize(&res->classes);
    286298        }
    287        
    288         list_initialize(&res->children);
    289         list_initialize(&res->match_ids.ids);
    290299       
    291300        return res;
     
    364373        if (NULL != cl) {
    365374                memset(cl, 0, sizeof(dev_class_t));
     375                list_initialize(&cl->devices);
    366376                fibril_mutex_initialize(&cl->mutex);
    367377        }
     
    394404dev_class_info_t * add_device_to_class(node_t *dev, dev_class_t *cl, const char *base_dev_name);
    395405
     406static inline void init_class_list(class_list_t *class_list)
     407{
     408        list_initialize(&class_list->classes);
     409        fibril_mutex_initialize(&class_list->classes_mutex);
     410}
     411
     412dev_class_t * get_dev_class(class_list_t *class_list, char *class_name);
     413dev_class_t * find_dev_class_no_lock(class_list_t *class_list, const char *class_name);
     414
     415static inline void add_dev_class_no_lock(class_list_t *class_list, dev_class_t *cl)
     416{
     417        list_append(&cl->link, &class_list->classes);
     418}
     419
    396420#endif
    397421
Note: See TracChangeset for help on using the changeset viewer.