Changeset e991937 in mainline
- Timestamp:
- 2013-08-07T12:10:51Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2757247
- Parents:
- d8d100c
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/main.c
rd8d100c re991937 89 89 90 90 /* High Speed, no bandwidth */ 91 ret = hcd_ddf_setup_ device(device, NULL, USB_SPEED_HIGH, 0, NULL);91 ret = hcd_ddf_setup_hc(device, USB_SPEED_HIGH, 0, NULL); 92 92 CHECK_RET_RETURN(ret, 93 93 "Failed to init generci hcd driver: %s\n", str_error(ret)); -
uspace/drv/bus/usb/ohci/ohci.c
rd8d100c re991937 131 131 132 132 /* Initialize generic HCD driver */ 133 ret = hcd_ddf_setup_ device(device, NULL, USB_SPEED_FULL,133 ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL, 134 134 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 135 135 if (ret != EOK) { -
uspace/drv/bus/usb/uhci/uhci.c
rd8d100c re991937 131 131 } 132 132 133 ret = hcd_ddf_setup_ device(device, NULL, USB_SPEED_FULL,133 ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL, 134 134 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 135 135 CHECK_RET_RETURN(ret, "Failed to setup UHCI HCD.\n"); -
uspace/drv/bus/usb/vhc/main.c
rd8d100c re991937 86 86 87 87 /* Initialize generic structures */ 88 ret = hcd_ddf_setup_ device(dev, NULL, USB_SPEED_FULL,88 ret = hcd_ddf_setup_hc(dev, USB_SPEED_FULL, 89 89 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 90 90 if (ret != EOK) { -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
rd8d100c re991937 43 43 usb_address_t address, usb_speed_t speed, const char *name, 44 44 const match_id_list_t *mids); 45 int hcd_ddf_setup_device(ddf_dev_t *device, ddf_fun_t **hc_fun, 46 usb_speed_t max_speed, size_t bw, bw_count_func_t bw_count); 45 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed, 46 size_t bw, bw_count_func_t bw_count); 47 void hcd_ddf_clean_hc(ddf_dev_t *device); 47 48 int hcd_ddf_setup_root_hub(ddf_dev_t *device); 48 49 int hcd_ddf_new_device(ddf_dev_t *device, usb_address_t *address); -
uspace/lib/usbhost/src/ddf_helpers.c
rd8d100c re991937 47 47 48 48 typedef struct hc_dev { 49 ddf_fun_t * hc_fun;49 ddf_fun_t *ctl_fun; 50 50 list_t devices; 51 51 fibril_mutex_t guard; 52 hcd_t hcd; 52 53 } hc_dev_t; 53 54 … … 60 61 { 61 62 hc_dev_t *hc_dev = dev_to_hc_dev(dev); 62 if (!hc_dev || !hc_dev->hc_fun) {63 if (!hc_dev) { 63 64 usb_log_error("Invalid HCD device.\n"); 64 65 return NULL; 65 66 } 66 return ddf_fun_data_get(hc_dev->hc_fun);67 return &hc_dev->hcd; 67 68 } 68 69 … … 563 564 * This function does all the ddf work for hc driver. 564 565 */ 565 int hcd_ddf_setup_device(ddf_dev_t *device, ddf_fun_t **hc_fun, 566 usb_speed_t max_speed, size_t bw, bw_count_func_t bw_count) 567 { 568 if (!device) 569 return EBADMEM; 570 571 int ret = ENOMEM; 566 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed, 567 size_t bw, bw_count_func_t bw_count) 568 { 569 assert(device); 570 572 571 hc_dev_t *instance = ddf_dev_data_alloc(device, sizeof(hc_dev_t)); 573 572 if (instance == NULL) { … … 577 576 list_initialize(&instance->devices); 578 577 fibril_mutex_initialize(&instance->guard); 579 580 instance->hc_fun = ddf_fun_create(device, fun_exposed, "hc"); 581 if (!instance->hc_fun) { 578 hcd_init(&instance->hcd, max_speed, bw, bw_count); 579 580 int ret = ENOMEM; 581 instance->ctl_fun = ddf_fun_create(device, fun_exposed, "ctl"); 582 if (!instance->ctl_fun) { 582 583 usb_log_error("Failed to create HCD ddf fun.\n"); 583 584 goto err_destroy_fun; 584 585 } 585 586 586 hcd_t *hcd = ddf_fun_data_alloc(instance->hc_fun, sizeof(hcd_t));587 if ( !instance->hc_fun) {588 usb_log_error("Failed to allocate HCD ddf fun data.\n");587 ret = ddf_fun_bind(instance->ctl_fun); 588 if (ret != EOK) { 589 usb_log_error("Failed to bind ctl_fun: %s.\n", str_error(ret)); 589 590 goto err_destroy_fun; 590 591 } 591 592 592 hcd_init(hcd, max_speed, bw, bw_count); 593 594 ret = ddf_fun_bind(instance->hc_fun); 595 if (ret != EOK) { 596 usb_log_error("Failed to bind hc_fun: %s.\n", str_error(ret)); 597 goto err_destroy_fun; 598 } 599 600 ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY); 593 ret = ddf_fun_add_to_category(instance->ctl_fun, USB_HC_CATEGORY); 601 594 if (ret != EOK) { 602 595 usb_log_error("Failed to add fun to category: %s.\n", 603 596 str_error(ret)); 604 ddf_fun_unbind(instance-> hc_fun);597 ddf_fun_unbind(instance->ctl_fun); 605 598 goto err_destroy_fun; 606 599 } 607 600 608 601 /* HC should be ok at this point (except it can't do anything) */ 609 if (hc_fun)610 *hc_fun = instance->hc_fun;611 602 return EOK; 612 603 613 604 err_destroy_fun: 614 ddf_fun_destroy(instance-> hc_fun);615 instance-> hc_fun = NULL;605 ddf_fun_destroy(instance->ctl_fun); 606 instance->ctl_fun = NULL; 616 607 return ret; 617 608 } 618 609 610 void hcd_ddf_clean_hc(ddf_dev_t *device) 611 { 612 assert(device); 613 hc_dev_t *hc = dev_to_hc_dev(device); 614 assert(hc); 615 const int ret = ddf_fun_unbind(hc->ctl_fun); 616 if (ret == EOK) 617 ddf_fun_destroy(hc->ctl_fun); 618 } 619 619 /** 620 620 * @}
Note:
See TracChangeset
for help on using the changeset viewer.