Changeset a33f0a6 in mainline for uspace/srv/devman/devman.c
- Timestamp:
- 2011-08-03T17:34:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1940326
- Parents:
- 52a79081 (diff), 3fab770 (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
-
uspace/srv/devman/devman.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
r52a79081 ra33f0a6 270 270 } 271 271 272 ssize_t read_bytes = safe_read(fd, buf, len);272 ssize_t read_bytes = read_all(fd, buf, len); 273 273 if (read_bytes <= 0) { 274 log_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path); 274 log_msg(LVL_ERROR, "Unable to read file '%s' (%zd).", conf_path, 275 read_bytes); 275 276 goto cleanup; 276 277 } … … 421 422 } 422 423 423 insert_fun_node(tree, fun, clone_string(""), NULL);424 insert_fun_node(tree, fun, str_dup(""), NULL); 424 425 match_id_t *id = create_match_id(); 425 id->id = clone_string("root");426 id->id = str_dup("root"); 426 427 id->score = 100; 427 428 add_match_id(&fun->match_ids, id); … … 466 467 fibril_mutex_lock(&drivers_list->drivers_mutex); 467 468 468 link_t *link = drivers_list->drivers.next; 469 while (link != &drivers_list->drivers) { 469 list_foreach(drivers_list->drivers, link) { 470 470 drv = list_get_instance(link, driver_t, drivers); 471 471 score = get_match_score(drv, node); … … 474 474 best_drv = drv; 475 475 } 476 link = link->next;477 476 } 478 477 … … 536 535 driver_t *res = NULL; 537 536 driver_t *drv = NULL; 538 link_t *link;539 537 540 538 fibril_mutex_lock(&drv_list->drivers_mutex); 541 539 542 link = drv_list->drivers.next; 543 while (link != &drv_list->drivers) { 540 list_foreach(drv_list->drivers, link) { 544 541 drv = list_get_instance(link, driver_t, drivers); 545 542 if (str_cmp(drv->name, drv_name) == 0) { … … 547 544 break; 548 545 } 549 550 link = link->next;551 546 } 552 547 … … 564 559 dev_node_t *dev; 565 560 link_t *link; 566 int phone;567 561 568 562 log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")", … … 570 564 571 565 fibril_mutex_lock(&driver->driver_mutex); 572 573 phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0); 574 575 if (phone < 0) { 566 567 async_exch_t *exch = async_exchange_begin(driver->sess); 568 async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch, 569 DRIVER_DEVMAN, 0, 0); 570 async_exchange_end(exch); 571 572 if (!sess) { 576 573 fibril_mutex_unlock(&driver->driver_mutex); 577 574 return; … … 582 579 * that has not been passed to the driver. 583 580 */ 584 link = driver->devices. next;585 while (link != &driver->devices ) {581 link = driver->devices.head.next; 582 while (link != &driver->devices.head) { 586 583 dev = list_get_instance(link, dev_node_t, driver_devices); 587 584 if (dev->passed_to_driver) { … … 602 599 fibril_mutex_unlock(&driver->driver_mutex); 603 600 604 add_device( phone, driver, dev, tree);601 add_device(sess, driver, dev, tree); 605 602 606 603 /* … … 620 617 * Restart the cycle to go through all devices again. 621 618 */ 622 link = driver->devices. next;623 } 624 625 async_hangup( phone);619 link = driver->devices.head.next; 620 } 621 622 async_hangup(sess); 626 623 627 624 /* … … 673 670 list_initialize(&drv->devices); 674 671 fibril_mutex_initialize(&drv->driver_mutex); 675 drv-> phone = -1;672 drv->sess = NULL; 676 673 } 677 674 … … 737 734 * @param node The device's node in the device tree. 738 735 */ 739 void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree) 736 void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev, 737 dev_tree_t *tree) 740 738 { 741 739 /* … … 746 744 drv->name, dev->pfun->name); 747 745 748 sysarg_t rc;749 ipc_call_t answer;750 751 746 /* Send the device to the driver. */ 752 747 devman_handle_t parent_handle; … … 756 751 parent_handle = 0; 757 752 } 758 759 aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle, 753 754 async_exch_t *exch = async_exchange_begin(sess); 755 756 ipc_call_t answer; 757 aid_t req = async_send_2(exch, DRIVER_ADD_DEVICE, dev->handle, 760 758 parent_handle, &answer); 761 759 762 /* Send the device 'sname to the driver. */763 rc = async_data_write_start(phone, dev->pfun->name,760 /* Send the device name to the driver. */ 761 sysarg_t rc = async_data_write_start(exch, dev->pfun->name, 764 762 str_size(dev->pfun->name) + 1); 763 764 async_exchange_end(exch); 765 765 766 if (rc != EOK) { 766 767 /* TODO handle error */ … … 823 824 if (is_running) { 824 825 /* Notify the driver about the new device. */ 825 int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0); 826 if (phone >= 0) { 827 add_device(phone, drv, dev, tree); 828 async_hangup(phone); 826 async_exch_t *exch = async_exchange_begin(drv->sess); 827 async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch, 828 DRIVER_DEVMAN, 0, 0); 829 async_exchange_end(exch); 830 831 if (sess) { 832 add_device(sess, drv, dev, tree); 833 async_hangup(sess); 829 834 } 830 835 } … … 1177 1182 1178 1183 fun_node_t *fun; 1179 link_t *link; 1180 1181 for (link = dev->functions.next; 1182 link != &dev->functions; 1183 link = link->next) { 1184 1185 list_foreach(dev->functions, link) { 1184 1186 fun = list_get_instance(link, fun_node_t, dev_functions); 1185 1187 … … 1375 1377 { 1376 1378 dev_class_t *cl; 1377 link_t *link = class_list->classes.next; 1378 1379 while (link != &class_list->classes) { 1379 1380 list_foreach(class_list->classes, link) { 1380 1381 cl = list_get_instance(link, dev_class_t, link); 1381 1382 if (str_cmp(cl->name, class_name) == 0) { 1382 1383 return cl; 1383 1384 } 1384 link = link->next;1385 1385 } 1386 1386 … … 1398 1398 assert(dev_name != NULL); 1399 1399 1400 link_t *link; 1401 for (link = dev_class->devices.next; 1402 link != &dev_class->devices; 1403 link = link->next) { 1400 list_foreach(dev_class->devices, link) { 1404 1401 dev_class_info_t *dev = list_get_instance(link, 1405 1402 dev_class_info_t, link);
Note:
See TracChangeset
for help on using the changeset viewer.
