Changeset cce3228 in mainline
- Timestamp:
- 2013-08-07T08:05:56Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e0d8b740
- Parents:
- dcbda00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
rdcbda00 rcce3228 603 603 usb_speed_t max_speed, size_t bw, bw_count_func_t bw_count) 604 604 { 605 if ( device == NULL)605 if (!device) 606 606 return EBADMEM; 607 607 608 int ret = ENOMEM; 608 609 hc_dev_t *instance = ddf_dev_data_alloc(device, sizeof(hc_dev_t)); 609 610 if (instance == NULL) { … … 614 615 fibril_mutex_initialize(&instance->guard); 615 616 616 #define CHECK_RET_DEST_FREE_RETURN(ret, message...) \617 if (ret != EOK) { \618 if (instance->hc_fun) { \619 ddf_fun_destroy(instance->hc_fun); \620 } \621 usb_log_error(message); \622 return ret; \623 } else (void)0624 625 617 instance->hc_fun = ddf_fun_create(device, fun_exposed, "hc"); 626 int ret = instance->hc_fun ? EOK : ENOMEM; 627 CHECK_RET_DEST_FREE_RETURN(ret, 628 "Failed to create HCD HC function: %s.\n", str_error(ret)); 618 if (!instance->hc_fun) { 619 usb_log_error("Failed to create HCD ddf fun.\n"); 620 goto err_destroy_fun; 621 } 622 629 623 hcd_t *hcd = ddf_fun_data_alloc(instance->hc_fun, sizeof(hcd_t)); 630 ret = hcd ? EOK : ENOMEM; 631 CHECK_RET_DEST_FREE_RETURN(ret, 632 "Failed to allocate HCD structure: %s.\n", str_error(ret)); 624 if (!instance->hc_fun) { 625 usb_log_error("Failed to allocate HCD ddf fun data.\n"); 626 goto err_destroy_fun; 627 } 633 628 634 629 hcd_init(hcd, max_speed, bw, bw_count); 635 630 636 631 ret = ddf_fun_bind(instance->hc_fun); 637 CHECK_RET_DEST_FREE_RETURN(ret, 638 "Failed to bind HCD device function: %s.\n", str_error(ret)); 639 640 #define CHECK_RET_UNBIND_FREE_RETURN(ret, message...) \ 641 if (ret != EOK) { \ 642 ddf_fun_unbind(instance->hc_fun); \ 643 CHECK_RET_DEST_FREE_RETURN(ret, message); \ 644 } else (void)0 632 if (ret != EOK) { 633 usb_log_error("Failed to bind hc_fun: %s.\n", str_error(ret)); 634 goto err_destroy_fun; 635 } 636 645 637 ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY); 646 CHECK_RET_UNBIND_FREE_RETURN(ret, 647 "Failed to add hc to category: %s\n", str_error(ret)); 638 if (ret != EOK) { 639 usb_log_error("Failed to add fun to category: %s.\n", 640 str_error(ret)); 641 ddf_fun_unbind(instance->hc_fun); 642 goto err_destroy_fun; 643 } 648 644 649 645 /* HC should be ok at this point (except it can't do anything) */ 650 646 if (hc_fun) 651 647 *hc_fun = instance->hc_fun; 652 653 648 return EOK; 649 650 err_destroy_fun: 651 ddf_fun_destroy(instance->hc_fun); 652 instance->hc_fun = NULL; 653 return ret; 654 654 } 655 655
Note:
See TracChangeset
for help on using the changeset viewer.