Changes in uspace/srv/devman/devman.c [c7bbf029:b72efe8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
rc7bbf029 rb72efe8 466 466 fibril_mutex_lock(&drivers_list->drivers_mutex); 467 467 468 link_t *link = drivers_list->drivers.next; 469 while (link != &drivers_list->drivers) { 468 list_foreach(drivers_list->drivers, link) { 470 469 drv = list_get_instance(link, driver_t, drivers); 471 470 score = get_match_score(drv, node); … … 474 473 best_drv = drv; 475 474 } 476 link = link->next;477 475 } 478 476 … … 536 534 driver_t *res = NULL; 537 535 driver_t *drv = NULL; 538 link_t *link;539 536 540 537 fibril_mutex_lock(&drv_list->drivers_mutex); 541 538 542 link = drv_list->drivers.next; 543 while (link != &drv_list->drivers) { 539 list_foreach(drv_list->drivers, link) { 544 540 drv = list_get_instance(link, driver_t, drivers); 545 541 if (str_cmp(drv->name, drv_name) == 0) { … … 547 543 break; 548 544 } 549 550 link = link->next;551 545 } 552 546 … … 564 558 dev_node_t *dev; 565 559 link_t *link; 566 int phone;567 560 568 561 log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")", … … 570 563 571 564 fibril_mutex_lock(&driver->driver_mutex); 572 573 phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0); 574 575 if (phone < 0) { 565 566 async_exch_t *exch = async_exchange_begin(driver->sess); 567 async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch, 568 DRIVER_DEVMAN, 0, 0); 569 async_exchange_end(exch); 570 571 if (!sess) { 576 572 fibril_mutex_unlock(&driver->driver_mutex); 577 573 return; … … 582 578 * that has not been passed to the driver. 583 579 */ 584 link = driver->devices. next;585 while (link != &driver->devices ) {580 link = driver->devices.head.next; 581 while (link != &driver->devices.head) { 586 582 dev = list_get_instance(link, dev_node_t, driver_devices); 587 583 if (dev->passed_to_driver) { … … 602 598 fibril_mutex_unlock(&driver->driver_mutex); 603 599 604 add_device( phone, driver, dev, tree);600 add_device(sess, driver, dev, tree); 605 601 606 602 /* … … 620 616 * Restart the cycle to go through all devices again. 621 617 */ 622 link = driver->devices. next;623 } 624 625 async_hangup( phone);618 link = driver->devices.head.next; 619 } 620 621 async_hangup(sess); 626 622 627 623 /* … … 673 669 list_initialize(&drv->devices); 674 670 fibril_mutex_initialize(&drv->driver_mutex); 675 drv-> phone = -1;671 drv->sess = NULL; 676 672 } 677 673 … … 737 733 * @param node The device's node in the device tree. 738 734 */ 739 void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree) 735 void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev, 736 dev_tree_t *tree) 740 737 { 741 738 /* … … 746 743 drv->name, dev->pfun->name); 747 744 748 sysarg_t rc;749 ipc_call_t answer;750 751 745 /* Send the device to the driver. */ 752 746 devman_handle_t parent_handle; … … 756 750 parent_handle = 0; 757 751 } 758 759 aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle, 752 753 async_exch_t *exch = async_exchange_begin(sess); 754 755 ipc_call_t answer; 756 aid_t req = async_send_2(exch, DRIVER_ADD_DEVICE, dev->handle, 760 757 parent_handle, &answer); 761 758 762 /* Send the device 'sname to the driver. */763 rc = async_data_write_start(phone, dev->pfun->name,759 /* Send the device name to the driver. */ 760 sysarg_t rc = async_data_write_start(exch, dev->pfun->name, 764 761 str_size(dev->pfun->name) + 1); 762 763 async_exchange_end(exch); 764 765 765 if (rc != EOK) { 766 766 /* TODO handle error */ … … 823 823 if (is_running) { 824 824 /* 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); 825 async_exch_t *exch = async_exchange_begin(drv->sess); 826 async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch, 827 DRIVER_DEVMAN, 0, 0); 828 async_exchange_end(exch); 829 830 if (sess) { 831 add_device(sess, drv, dev, tree); 832 async_hangup(sess); 829 833 } 830 834 } … … 1177 1181 1178 1182 fun_node_t *fun; 1179 link_t *link; 1180 1181 for (link = dev->functions.next; 1182 link != &dev->functions; 1183 link = link->next) { 1183 1184 list_foreach(dev->functions, link) { 1184 1185 fun = list_get_instance(link, fun_node_t, dev_functions); 1185 1186 … … 1375 1376 { 1376 1377 dev_class_t *cl; 1377 link_t *link = class_list->classes.next; 1378 1379 while (link != &class_list->classes) { 1378 1379 list_foreach(class_list->classes, link) { 1380 1380 cl = list_get_instance(link, dev_class_t, link); 1381 1381 if (str_cmp(cl->name, class_name) == 0) { 1382 1382 return cl; 1383 1383 } 1384 link = link->next;1385 1384 } 1386 1385 … … 1398 1397 assert(dev_name != NULL); 1399 1398 1400 link_t *link; 1401 for (link = dev_class->devices.next; 1402 link != &dev_class->devices; 1403 link = link->next) { 1399 list_foreach(dev_class->devices, link) { 1404 1400 dev_class_info_t *dev = list_get_instance(link, 1405 1401 dev_class_info_t, link);
Note:
See TracChangeset
for help on using the changeset viewer.