Changeset b2d06fa in mainline for uspace/srv/devman/devman.c
- Timestamp:
- 2010-12-25T17:14:36Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r59e9398b rb2d06fa 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 }; … … 368 384 printf(NAME ": create_root_node\n"); 369 385 386 fibril_rwlock_write_lock(&tree->rwlock); 370 387 node = create_dev_node(); 371 388 if (node != NULL) { … … 377 394 tree->root_node = node; 378 395 } 396 fibril_rwlock_write_unlock(&tree->rwlock); 379 397 380 398 return node != NULL; … … 439 457 /** Start a driver 440 458 * 441 * The driver's mutex is assumed to be locked.442 *443 459 * @param drv The driver's structure. 444 460 * @return True if the driver's task is successfully spawned, false … … 449 465 int rc; 450 466 467 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 468 451 469 printf(NAME ": start_driver '%s'\n", drv->name); 452 470 … … 670 688 } 671 689 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); 673 692 674 693 tree_add_devmap_device(tree, node); … … 842 861 /** Find the device node structure of the device witch has the specified handle. 843 862 * 844 * Device tree's rwlock should be held at least for reading.845 *846 863 * @param tree The device tree where we look for the device node. 847 864 * @param handle The handle of the device. … … 851 868 { 852 869 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); 854 875 return hash_table_get_instance(link, node_t, devman_link); 855 876 } … … 907 928 /** Insert new device into device tree. 908 929 * 909 * The device tree's rwlock should be already held exclusively when calling this910 * function.911 *912 930 * @param tree The device tree. 913 931 * @param node The newly added device node. … … 924 942 assert(tree != NULL); 925 943 assert(dev_name != NULL); 944 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 926 945 927 946 node->name = dev_name; … … 1042 1061 1043 1062 info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t)); 1044 if (info != NULL) 1063 if (info != NULL) { 1045 1064 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 } 1046 1069 1047 1070 return info; … … 1167 1190 fibril_rwlock_initialize(&class_list->rwlock); 1168 1191 hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1, 1169 &devmap_devices_ ops);1192 &devmap_devices_class_ops); 1170 1193 } 1171 1194 … … 1215 1238 hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link); 1216 1239 fibril_rwlock_write_unlock(&class_list->rwlock); 1240 1241 assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL); 1217 1242 } 1218 1243
Note:
See TracChangeset
for help on using the changeset viewer.