Changeset 2b0db98 in mainline for uspace/srv/devman/devman.c
- Timestamp:
- 2011-01-07T14:02:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6986418
- Parents:
- d99120f (diff), 0f191a2 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
rd99120f r2b0db98 62 62 } 63 63 64 static 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 64 74 static void devices_remove_callback(link_t *item) 65 75 { … … 75 85 .hash = devices_hash, 76 86 .compare = devmap_devices_compare, 87 .remove_callback = devices_remove_callback 88 }; 89 90 static hash_table_operations_t devmap_devices_class_ops = { 91 .hash = devices_hash, 92 .compare = devmap_devices_class_compare, 77 93 .remove_callback = devices_remove_callback 78 94 }; … … 376 392 printf(NAME ": create_root_node\n"); 377 393 394 fibril_rwlock_write_lock(&tree->rwlock); 378 395 node = create_dev_node(); 379 396 if (node != NULL) { … … 385 402 tree->root_node = node; 386 403 } 404 fibril_rwlock_write_unlock(&tree->rwlock); 387 405 388 406 return node != NULL; … … 447 465 /** Start a driver 448 466 * 449 * The driver's mutex is assumed to be locked.450 *451 467 * @param drv The driver's structure. 452 468 * @return True if the driver's task is successfully spawned, false … … 457 473 int rc; 458 474 475 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 476 459 477 printf(NAME ": start_driver '%s'\n", drv->name); 460 478 … … 678 696 } 679 697 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); 681 700 682 701 tree_add_devmap_device(tree, node); … … 850 869 /** Find the device node structure of the device witch has the specified handle. 851 870 * 852 * Device tree's rwlock should be held at least for reading.853 *854 871 * @param tree The device tree where we look for the device node. 855 872 * @param handle The handle of the device. … … 859 876 { 860 877 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); 862 883 return hash_table_get_instance(link, node_t, devman_link); 863 884 } … … 915 936 /** Insert new device into device tree. 916 937 * 917 * The device tree's rwlock should be already held exclusively when calling this918 * function.919 *920 938 * @param tree The device tree. 921 939 * @param node The newly added device node. … … 932 950 assert(tree != NULL); 933 951 assert(dev_name != NULL); 952 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 934 953 935 954 node->name = dev_name; … … 1050 1069 1051 1070 info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t)); 1052 if (info != NULL) 1071 if (info != NULL) { 1053 1072 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 } 1054 1077 1055 1078 return info; … … 1175 1198 fibril_rwlock_initialize(&class_list->rwlock); 1176 1199 hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1, 1177 &devmap_devices_ ops);1200 &devmap_devices_class_ops); 1178 1201 } 1179 1202 … … 1223 1246 hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link); 1224 1247 fibril_rwlock_write_unlock(&class_list->rwlock); 1248 1249 assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL); 1225 1250 } 1226 1251
Note:
See TracChangeset
for help on using the changeset viewer.