Changeset e6edc8d1 in mainline for uspace/drv/bus/usb/ehci/main.c
- Timestamp:
- 2013-07-11T19:13:37Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67632f7
- Parents:
- 52ff62d3 (diff), 2b3e8840 (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
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/main.c
r52ff62d3 re6edc8d1 33 33 * Main routines of EHCI driver. 34 34 */ 35 35 36 #include <ddf/driver.h> 36 37 #include <ddf/interrupt.h> 37 38 #include <device/hw_res.h> 38 39 #include <errno.h> 40 #include <stdbool.h> 39 41 #include <str_error.h> 40 42 … … 70 72 static int ehci_dev_add(ddf_dev_t *device) 71 73 { 74 ddf_fun_t *hc_fun = NULL; 75 bool fun_bound = false; 76 72 77 assert(device); 73 #define CHECK_RET_RETURN(ret, message...) \74 if (ret != EOK) { \75 usb_log_error(message); \76 return ret; \77 }78 78 79 79 uintptr_t reg_base = 0; … … 81 81 int irq = 0; 82 82 83 int ret = get_my_registers(device, ®_base, ®_size, &irq); 84 CHECK_RET_RETURN(ret, 85 "Failed to get memory addresses for %" PRIun ": %s.\n", 86 ddf_dev_get_handle(device), str_error(ret)); 83 int rc = get_my_registers(device, ®_base, ®_size, &irq); 84 if (rc != EOK) { 85 usb_log_error("Failed to get memory addresses for %" PRIun 86 ": %s.\n", ddf_dev_get_handle(device), str_error(rc)); 87 goto error; 88 } 89 87 90 usb_log_info("Memory mapped regs at 0x%" PRIxn " (size %zu), IRQ %d.\n", 88 91 reg_base, reg_size, irq); 89 92 90 ret = disable_legacy(device, reg_base, reg_size); 91 CHECK_RET_RETURN(ret, 92 "Failed to disable legacy USB: %s.\n", str_error(ret)); 93 rc = disable_legacy(device, reg_base, reg_size); 94 if (rc != EOK) { 95 usb_log_error("Failed to disable legacy USB: %s.\n", 96 str_error(rc)); 97 goto error; 98 } 93 99 94 ddf_fun_t *hc_fun = ddf_fun_create(device, fun_exposed, "ehci_hc");100 hc_fun = ddf_fun_create(device, fun_exposed, "ehci_hc"); 95 101 if (hc_fun == NULL) { 96 102 usb_log_error("Failed to create EHCI function.\n"); 97 return ENOMEM; 103 rc = ENOMEM; 104 goto error; 98 105 } 106 99 107 hcd_t *ehci_hc = ddf_fun_data_alloc(hc_fun, sizeof(hcd_t)); 100 108 if (ehci_hc == NULL) { 101 109 usb_log_error("Failed to alloc generic HC driver.\n"); 102 return ENOMEM; 110 rc = ENOMEM; 111 goto error; 103 112 } 113 104 114 /* High Speed, no bandwidth */ 105 115 hcd_init(ehci_hc, USB_SPEED_HIGH, 0, NULL); 106 116 ddf_fun_set_ops(hc_fun, &hc_ops); 107 117 108 ret = ddf_fun_bind(hc_fun); 109 CHECK_RET_RETURN(ret, 110 "Failed to bind EHCI function: %s.\n", 111 str_error(ret)); 112 ret = ddf_fun_add_to_category(hc_fun, USB_HC_CATEGORY); 113 CHECK_RET_RETURN(ret, 114 "Failed to add EHCI to HC class: %s.\n", 115 str_error(ret)); 118 rc = ddf_fun_bind(hc_fun); 119 if (rc != EOK) { 120 usb_log_error("Failed to bind EHCI function: %s.\n", 121 str_error(rc)); 122 goto error; 123 } 124 125 fun_bound = true; 126 127 rc = ddf_fun_add_to_category(hc_fun, USB_HC_CATEGORY); 128 if (rc != EOK) { 129 usb_log_error("Failed to add EHCI to HC class: %s.\n", 130 str_error(rc)); 131 goto error; 132 } 116 133 117 134 usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n", … … 119 136 120 137 return EOK; 121 #undef CHECK_RET_RETURN 138 error: 139 if (fun_bound) 140 ddf_fun_unbind(hc_fun); 141 if (hc_fun != NULL) 142 ddf_fun_destroy(hc_fun); 143 return rc; 122 144 } 123 145
Note:
See TracChangeset
for help on using the changeset viewer.