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


Ignore:
Timestamp:
2010-06-01T19:49:48Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a32defa
Parents:
5159ae9
Message:

Add the 'class' namespace to the device mapper. When a driver adds a device to a class, the device is registered with its class specific name by the device mapper in the 'class' namespace.

File:
1 edited

Legend:

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

    r5159ae9 rce89036b  
    831831{
    832832        dev_class_t *cl;
    833         fibril_mutex_lock(&class_list->classes_mutex); 
     833        fibril_rwlock_write_lock(&class_list->rwlock); 
    834834        cl = find_dev_class_no_lock(class_list, class_name);
    835835        if (NULL == cl) {
     
    841841                }               
    842842        }       
    843         fibril_mutex_unlock(&class_list->classes_mutex);
     843        fibril_rwlock_write_unlock(&class_list->rwlock);
    844844        return cl;
    845845}
     
    859859}
    860860
     861void init_class_list(class_list_t *class_list)
     862{
     863        list_initialize(&class_list->classes);
     864        fibril_rwlock_initialize(&class_list->rwlock);
     865        hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1, &devmap_devices_ops);
     866}
     867
     868
     869// devmap devices
     870
     871node_t *find_devmap_tree_device(dev_tree_t *tree, dev_handle_t devmap_handle)
     872{
     873        node_t *dev = NULL;
     874        link_t *link;
     875        unsigned long key = (unsigned long)devmap_handle;
     876       
     877        fibril_rwlock_read_lock(&tree->rwlock);
     878        link = hash_table_find(&tree->devmap_devices, &key);   
     879        if (NULL != link) {
     880                dev = hash_table_get_instance(link, node_t, devmap_link);
     881        }
     882        fibril_rwlock_read_unlock(&tree->rwlock);
     883       
     884        return dev;
     885}
     886
     887node_t *find_devmap_class_device(class_list_t *classes, dev_handle_t devmap_handle)
     888{
     889        node_t *dev = NULL;
     890        dev_class_info_t *cli;
     891        link_t *link;
     892        unsigned long key = (unsigned long)devmap_handle;
     893       
     894        fibril_rwlock_read_lock(&classes->rwlock);
     895        link = hash_table_find(&classes->devmap_devices, &key);
     896        if (NULL != link) {
     897                cli = hash_table_get_instance(link, dev_class_info_t, devmap_link);
     898                dev = cli->dev;
     899        }
     900        fibril_rwlock_read_unlock(&classes->rwlock);
     901       
     902        return dev;     
     903}
     904
     905
    861906/** @}
    862907 */
Note: See TracChangeset for help on using the changeset viewer.