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


Ignore:
Timestamp:
2010-12-25T17:14:36Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
092e4f1
Parents:
59e9398b (diff), 3ac66f69 (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 mainline changes.

File:
1 edited

Legend:

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

    r59e9398b rb2d06fa  
    6262}
    6363
     64static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys,
     65    link_t *item)
     66{
     67        dev_class_info_t *class_info
     68            = hash_table_get_instance(item, dev_class_info_t, devmap_link);
     69        assert(class_info != NULL);
     70
     71        return (class_info->devmap_handle == (devmap_handle_t) key[0]);
     72}
     73
    6474static void devices_remove_callback(link_t *item)
    6575{
     
    7585        .hash = devices_hash,
    7686        .compare = devmap_devices_compare,
     87        .remove_callback = devices_remove_callback
     88};
     89
     90static hash_table_operations_t devmap_devices_class_ops = {
     91        .hash = devices_hash,
     92        .compare = devmap_devices_class_compare,
    7793        .remove_callback = devices_remove_callback
    7894};
     
    368384        printf(NAME ": create_root_node\n");
    369385
     386        fibril_rwlock_write_lock(&tree->rwlock);
    370387        node = create_dev_node();
    371388        if (node != NULL) {
     
    377394                tree->root_node = node;
    378395        }
     396        fibril_rwlock_write_unlock(&tree->rwlock);
    379397
    380398        return node != NULL;
     
    439457/** Start a driver
    440458 *
    441  * The driver's mutex is assumed to be locked.
    442  *
    443459 * @param drv           The driver's structure.
    444460 * @return              True if the driver's task is successfully spawned, false
     
    449465        int rc;
    450466
     467        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     468       
    451469        printf(NAME ": start_driver '%s'\n", drv->name);
    452470       
     
    670688        }
    671689       
    672         devmap_device_register(devmap_pathname, &node->devmap_handle);
     690        devmap_device_register_with_iface(devmap_pathname,
     691            &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    673692       
    674693        tree_add_devmap_device(tree, node);
     
    842861/** Find the device node structure of the device witch has the specified handle.
    843862 *
    844  * Device tree's rwlock should be held at least for reading.
    845  *
    846863 * @param tree          The device tree where we look for the device node.
    847864 * @param handle        The handle of the device.
     
    851868{
    852869        unsigned long key = handle;
    853         link_t *link = hash_table_find(&tree->devman_devices, &key);
     870        link_t *link;
     871       
     872        assert(fibril_rwlock_is_locked(&tree->rwlock));
     873       
     874        link = hash_table_find(&tree->devman_devices, &key);
    854875        return hash_table_get_instance(link, node_t, devman_link);
    855876}
     
    907928/** Insert new device into device tree.
    908929 *
    909  * The device tree's rwlock should be already held exclusively when calling this
    910  * function.
    911  *
    912930 * @param tree          The device tree.
    913931 * @param node          The newly added device node.
     
    924942        assert(tree != NULL);
    925943        assert(dev_name != NULL);
     944        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    926945       
    927946        node->name = dev_name;
     
    10421061       
    10431062        info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
    1044         if (info != NULL)
     1063        if (info != NULL) {
    10451064                memset(info, 0, sizeof(dev_class_info_t));
     1065                list_initialize(&info->dev_classes);
     1066                list_initialize(&info->devmap_link);
     1067                list_initialize(&info->link);
     1068        }
    10461069       
    10471070        return info;
     
    11671190        fibril_rwlock_initialize(&class_list->rwlock);
    11681191        hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
    1169             &devmap_devices_ops);
     1192            &devmap_devices_class_ops);
    11701193}
    11711194
     
    12151238        hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
    12161239        fibril_rwlock_write_unlock(&class_list->rwlock);
     1240
     1241        assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
    12171242}
    12181243
Note: See TracChangeset for help on using the changeset viewer.