Changeset fb7e5a9a in mainline for uspace/srv/devman/main.c
- Timestamp:
- 2011-09-06T20:03:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 038b289, f7d6b30
- Parents:
- 7a46bfe (diff), 7e9fce6 (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/main.c
r7a46bfe rfb7e5a9a 316 316 if (fun->child != NULL) { 317 317 dev_node_t *dev = fun->child; 318 device_state_t dev_state; 318 319 319 320 dev_add_ref(dev); 321 dev_state = dev->state; 322 320 323 fibril_rwlock_write_unlock(&device_tree.rwlock); 321 324 322 325 /* If device is owned by driver, ask driver to give it up. */ 323 if (dev ->state == DEVICE_USABLE) {326 if (dev_state == DEVICE_USABLE) { 324 327 rc = driver_dev_remove(&device_tree, dev); 325 328 if (rc != EOK) { … … 333 336 if (!list_empty(&dev->functions)) { 334 337 fibril_rwlock_read_unlock(&device_tree.rwlock); 338 dev_del_ref(dev); 335 339 return EIO; 336 340 } 341 337 342 driver_t *driver = dev->drv; 338 343 fibril_rwlock_read_unlock(&device_tree.rwlock); … … 507 512 fun_node_t *fun; 508 513 int rc; 509 510 printf("devman_drv_fun_online()\n"); 514 515 log_msg(LVL_DEBUG, "devman_drv_fun_online()"); 516 511 517 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 512 518 if (fun == NULL) { … … 526 532 rc = online_function(fun); 527 533 if (rc != EOK) { 528 printf("devman_drv_fun_online() online_fun->ERROR\n");529 534 fun_del_ref(fun); 530 535 async_answer_0(iid, (sysarg_t) rc); … … 533 538 534 539 fun_del_ref(fun); 535 printf("devman_drv_fun_online() online_fun->OK\n");536 540 537 541 async_answer_0(iid, (sysarg_t) EOK); … … 580 584 int rc; 581 585 582 583 586 fun_node_t *fun = find_fun_node(&device_tree, fun_handle); 584 587 if (fun == NULL) { … … 599 602 600 603 if (fun->ftype == fun_inner) { 601 /* Handle possible descendants */ 602 /* TODO - This is a surprise removal */ 604 /* This is a surprise removal. Handle possible descendants */ 603 605 if (fun->child != NULL) { 604 log_msg(LVL_WARN, "devman_remove_function(): not handling " 605 "descendants\n"); 606 dev_node_t *dev = fun->child; 607 device_state_t dev_state; 608 int gone_rc; 609 610 dev_add_ref(dev); 611 dev_state = dev->state; 612 613 fibril_rwlock_write_unlock(&device_tree.rwlock); 614 615 /* If device is owned by driver, inform driver it is gone. */ 616 if (dev_state == DEVICE_USABLE) 617 gone_rc = driver_dev_gone(&device_tree, dev); 618 else 619 gone_rc = EOK; 620 621 fibril_rwlock_read_lock(&device_tree.rwlock); 622 623 /* Verify that driver succeeded and removed all functions */ 624 if (gone_rc != EOK || !list_empty(&dev->functions)) { 625 log_msg(LVL_ERROR, "Driver did not remove " 626 "functions for device that is gone. " 627 "Device node is now defunct."); 628 629 /* 630 * Not much we can do but mark the device 631 * node as having invalid state. This 632 * is a driver bug. 633 */ 634 dev->state = DEVICE_INVALID; 635 fibril_rwlock_read_unlock(&device_tree.rwlock); 636 dev_del_ref(dev); 637 return; 638 } 639 640 driver_t *driver = dev->drv; 641 fibril_rwlock_read_unlock(&device_tree.rwlock); 642 643 if (driver) 644 detach_driver(&device_tree, dev); 645 646 fibril_rwlock_write_lock(&device_tree.rwlock); 647 remove_dev_node(&device_tree, dev); 648 649 /* Delete ref created when node was inserted */ 650 dev_del_ref(dev); 651 /* Delete ref created by dev_add_ref(dev) above */ 652 dev_del_ref(dev); 606 653 } 607 654 } else {
Note:
See TracChangeset
for help on using the changeset viewer.