Changeset d0dd7b5 in mainline for uspace/srv/devman
- Timestamp:
- 2011-08-18T20:10:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef7052ec
- Parents:
- 763e0cd
- Location:
- uspace/srv/devman
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r763e0cd rd0dd7b5 1100 1100 } 1101 1101 1102 /** Remove function from device tree. 1103 * 1104 * @param tree Device tree 1105 * @param node Function node to remove 1106 */ 1107 void remove_fun_node(dev_tree_t *tree, fun_node_t *fun) 1108 { 1109 assert(tree != NULL); 1110 assert(fun != NULL); 1111 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 1112 1113 /* Remove the node from the handle-to-node map. */ 1114 unsigned long key = fun->handle; 1115 hash_table_remove(&tree->devman_functions, &key, 1); 1116 1117 /* Remove the node from the list of its parent's children. */ 1118 if (fun->dev != NULL) 1119 list_remove(&fun->dev_functions); 1120 } 1121 1102 1122 /** Find function node with a specified path in the device tree. 1103 1123 * -
uspace/srv/devman/devman.h
r763e0cd rd0dd7b5 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 154 155 /** Name of the function, assigned by the device driver */ 155 156 char *name; 157 /** Function type */ 158 fun_type_t ftype; 156 159 157 160 /** Full path and name of the device in device hierarchy */ … … 265 268 extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *); 266 269 extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *); 270 extern void remove_fun_node(dev_tree_t *, fun_node_t *); 267 271 268 272 /* Loc services */ -
uspace/srv/devman/main.c
r763e0cd rd0dd7b5 278 278 return; 279 279 } 280 280 281 281 fun_node_t *fun = create_fun_node(); 282 fun->ftype = ftype; 283 282 284 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { 283 285 fibril_rwlock_write_unlock(&tree->rwlock); … … 367 369 } 368 370 371 /** Remove function. */ 372 static void devman_remove_function(ipc_callid_t callid, ipc_call_t *call) 373 { 374 devman_handle_t fun_handle = IPC_GET_ARG1(*call); 375 dev_tree_t *tree = &device_tree; 376 int rc; 377 378 fibril_rwlock_write_lock(&tree->rwlock); 379 380 fun_node_t *fun = find_fun_node_no_lock(&device_tree, fun_handle); 381 if (fun == NULL) { 382 fibril_rwlock_write_unlock(&tree->rwlock); 383 async_answer_0(callid, ENOENT); 384 return; 385 } 386 387 log_msg(LVL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname); 388 389 if (fun->ftype == fun_inner) { 390 /* Handle possible descendants */ 391 /* TODO */ 392 log_msg(LVL_WARN, "devman_remove_function(): not handling " 393 "descendants\n"); 394 } else { 395 /* Unregister from location service */ 396 rc = loc_service_unregister(fun->service_id); 397 if (rc != EOK) { 398 log_msg(LVL_ERROR, "Failed unregistering tree service."); 399 fibril_rwlock_write_unlock(&tree->rwlock); 400 async_answer_0(callid, EIO); 401 return; 402 } 403 } 404 405 remove_fun_node(&device_tree, fun); 406 fibril_rwlock_write_unlock(&tree->rwlock); 407 delete_fun_node(fun); 408 409 log_msg(LVL_DEBUG, "devman_remove_function() succeeded."); 410 async_answer_0(callid, EOK); 411 } 412 369 413 /** Initialize driver which has registered itself as running and ready. 370 414 * … … 418 462 case DEVMAN_ADD_DEVICE_TO_CATEGORY: 419 463 devman_add_function_to_cat(callid, &call); 464 break; 465 case DEVMAN_REMOVE_FUNCTION: 466 devman_remove_function(callid, &call); 420 467 break; 421 468 default:
Note:
See TracChangeset
for help on using the changeset viewer.