Changeset fc8c2b6 in mainline
- Timestamp:
- 2011-03-30T14:26:13Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e72fb34
- Parents:
- 3fddb55
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/ipc/devman.h
r3fddb55 rfc8c2b6 148 148 149 149 typedef enum { 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS 151 152 } client_to_devman_t; 152 153 -
uspace/srv/devman/devman.c
r3fddb55 rfc8c2b6 1194 1194 } 1195 1195 1196 /** Find function node by its class name and index. */ 1197 fun_node_t *find_fun_node_by_class(class_list_t *class_list, 1198 const char *class_name, const char *dev_name) 1199 { 1200 assert(class_list != NULL); 1201 assert(class_name != NULL); 1202 assert(dev_name != NULL); 1203 1204 fibril_rwlock_read_lock(&class_list->rwlock); 1205 1206 dev_class_t *cl = find_dev_class_no_lock(class_list, class_name); 1207 if (cl == NULL) { 1208 fibril_rwlock_read_unlock(&class_list->rwlock); 1209 return NULL; 1210 } 1211 1212 dev_class_info_t *dev = find_dev_in_class(cl, dev_name); 1213 if (dev == NULL) { 1214 fibril_rwlock_read_unlock(&class_list->rwlock); 1215 return NULL; 1216 } 1217 1218 fun_node_t *fun = dev->fun; 1219 1220 fibril_rwlock_read_unlock(&class_list->rwlock); 1221 1222 return fun; 1223 } 1224 1225 1196 1226 /** Find child function node with a specified name. 1197 1227 * … … 1366 1396 } 1367 1397 1398 dev_class_info_t *find_dev_in_class(dev_class_t *dev_class, const char *dev_name) 1399 { 1400 assert(dev_class != NULL); 1401 assert(dev_name != NULL); 1402 1403 link_t *link; 1404 for (link = dev_class->devices.next; 1405 link != &dev_class->devices; 1406 link = link->next) { 1407 dev_class_info_t *dev = list_get_instance(link, 1408 dev_class_info_t, link); 1409 1410 if (str_cmp(dev->dev_name, dev_name) == 0) { 1411 return dev; 1412 } 1413 } 1414 1415 return NULL; 1416 } 1417 1368 1418 void init_class_list(class_list_t *class_list) 1369 1419 { -
uspace/srv/devman/devman.h
r3fddb55 rfc8c2b6 339 339 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *); 340 340 extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *); 341 extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *); 341 342 342 343 /* Device tree */ … … 360 361 extern dev_class_t *get_dev_class(class_list_t *, char *); 361 362 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *); 363 extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *); 362 364 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *); 363 365 -
uspace/srv/devman/main.c
r3fddb55 rfc8c2b6 448 448 } 449 449 450 /** Find handle for the device instance identified by device class name. */ 451 static void devman_function_get_handle_by_class(ipc_callid_t iid, 452 ipc_call_t *icall) 453 { 454 char *classname; 455 char *devname; 456 457 int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0); 458 if (rc != EOK) { 459 async_answer_0(iid, rc); 460 return; 461 } 462 rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0); 463 if (rc != EOK) { 464 free(classname); 465 async_answer_0(iid, rc); 466 return; 467 } 468 469 470 fun_node_t *fun = find_fun_node_by_class(&class_list, 471 classname, devname); 472 473 free(classname); 474 free(devname); 475 476 if (fun == NULL) { 477 async_answer_0(iid, ENOENT); 478 return; 479 } 480 481 async_answer_1(iid, EOK, fun->handle); 482 } 483 450 484 451 485 /** Function for handling connections from a client to the device manager. */ … … 466 500 case DEVMAN_DEVICE_GET_HANDLE: 467 501 devman_function_get_handle(callid, &call); 502 break; 503 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS: 504 devman_function_get_handle_by_class(callid, &call); 468 505 break; 469 506 default:
Note:
See TracChangeset
for help on using the changeset viewer.