Changeset 93fb170c in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-01-08T18:51:31Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
15be932
Parents:
8f748215 (diff), a523af4 (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 main branch

File:
1 edited

Legend:

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

    r8f748215 r93fb170c  
    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};
     
    376392        printf(NAME ": create_root_node\n");
    377393
     394        fibril_rwlock_write_lock(&tree->rwlock);
    378395        node = create_dev_node();
    379396        if (node != NULL) {
     
    385402                tree->root_node = node;
    386403        }
     404        fibril_rwlock_write_unlock(&tree->rwlock);
    387405
    388406        return node != NULL;
     
    447465/** Start a driver
    448466 *
    449  * The driver's mutex is assumed to be locked.
    450  *
    451467 * @param drv           The driver's structure.
    452468 * @return              True if the driver's task is successfully spawned, false
     
    457473        int rc;
    458474
     475        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     476       
    459477        printf(NAME ": start_driver '%s'\n", drv->name);
    460478       
     
    678696        }
    679697       
    680         devmap_device_register(devmap_pathname, &node->devmap_handle);
     698        devmap_device_register_with_iface(devmap_pathname,
     699            &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    681700       
    682701        tree_add_devmap_device(tree, node);
     
    850869/** Find the device node structure of the device witch has the specified handle.
    851870 *
    852  * Device tree's rwlock should be held at least for reading.
    853  *
    854871 * @param tree          The device tree where we look for the device node.
    855872 * @param handle        The handle of the device.
     
    859876{
    860877        unsigned long key = handle;
    861         link_t *link = hash_table_find(&tree->devman_devices, &key);
     878        link_t *link;
     879       
     880        assert(fibril_rwlock_is_locked(&tree->rwlock));
     881       
     882        link = hash_table_find(&tree->devman_devices, &key);
    862883        return hash_table_get_instance(link, node_t, devman_link);
    863884}
     
    915936/** Insert new device into device tree.
    916937 *
    917  * The device tree's rwlock should be already held exclusively when calling this
    918  * function.
    919  *
    920938 * @param tree          The device tree.
    921939 * @param node          The newly added device node.
     
    932950        assert(tree != NULL);
    933951        assert(dev_name != NULL);
     952        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    934953       
    935954        node->name = dev_name;
     
    10501069       
    10511070        info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
    1052         if (info != NULL)
     1071        if (info != NULL) {
    10531072                memset(info, 0, sizeof(dev_class_info_t));
     1073                list_initialize(&info->dev_classes);
     1074                list_initialize(&info->devmap_link);
     1075                list_initialize(&info->link);
     1076        }
    10541077       
    10551078        return info;
     
    11751198        fibril_rwlock_initialize(&class_list->rwlock);
    11761199        hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
    1177             &devmap_devices_ops);
     1200            &devmap_devices_class_ops);
    11781201}
    11791202
     
    12231246        hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
    12241247        fibril_rwlock_write_unlock(&class_list->rwlock);
     1248
     1249        assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
    12251250}
    12261251
Note: See TracChangeset for help on using the changeset viewer.