Changes in uspace/srv/devman/main.c [80a96d2:f278930] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r80a96d2 rf278930 316 316 if (fun->child != NULL) { 317 317 dev_node_t *dev = fun->child; 318 device_state_t dev_state;319 318 320 319 dev_add_ref(dev); 321 dev_state = dev->state;320 fibril_rwlock_write_unlock(&device_tree.rwlock); 322 321 323 fibril_rwlock_write_unlock(&device_tree.rwlock);324 325 322 /* If device is owned by driver, ask driver to give it up. */ 326 if (dev _state == DEVICE_USABLE) {323 if (dev->state == DEVICE_USABLE) { 327 324 rc = driver_dev_remove(&device_tree, dev); 328 325 if (rc != EOK) { … … 336 333 if (!list_empty(&dev->functions)) { 337 334 fibril_rwlock_read_unlock(&device_tree.rwlock); 338 dev_del_ref(dev);339 335 return EIO; 340 336 } 341 342 337 driver_t *driver = dev->drv; 343 338 fibril_rwlock_read_unlock(&device_tree.rwlock); … … 512 507 fun_node_t *fun; 513 508 int rc; 514 515 log_msg(LVL_DEBUG, "devman_drv_fun_online()"); 516 509 510 printf("devman_drv_fun_online()\n"); 517 511 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 518 512 if (fun == NULL) { … … 532 526 rc = online_function(fun); 533 527 if (rc != EOK) { 528 printf("devman_drv_fun_online() online_fun->ERROR\n"); 534 529 fun_del_ref(fun); 535 530 async_answer_0(iid, (sysarg_t) rc); … … 538 533 539 534 fun_del_ref(fun); 535 printf("devman_drv_fun_online() online_fun->OK\n"); 540 536 541 537 async_answer_0(iid, (sysarg_t) EOK); … … 584 580 int rc; 585 581 582 586 583 fun_node_t *fun = find_fun_node(&device_tree, fun_handle); 587 584 if (fun == NULL) { … … 602 599 603 600 if (fun->ftype == fun_inner) { 604 /* This is a surprise removal. Handle possible descendants */ 601 /* Handle possible descendants */ 602 /* TODO - This is a surprise removal */ 605 603 if (fun->child != NULL) { 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); 604 log_msg(LVL_WARN, "devman_remove_function(): not handling " 605 "descendants\n"); 653 606 } 654 607 } else {
Note:
See TracChangeset
for help on using the changeset viewer.