Changeset 62265ce in mainline
- Timestamp:
- 2011-05-07T14:26:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dc5f2fb
- Parents:
- 7ab7c7f6
- Location:
- uspace/drv/ohci
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r7ab7c7f6 r62265ce 95 95 } 96 96 /*----------------------------------------------------------------------------*/ 97 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 98 uintptr_t regs, size_t reg_size, bool interrupts) 97 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 99 98 { 100 99 assert(instance); -
uspace/drv/ohci/hc.h
r7ab7c7f6 r62265ce 77 77 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 78 79 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 80 uintptr_t regs, size_t reg_size, bool interrupts); 79 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 81 80 82 81 void hc_start_hw(hc_t *instance); -
uspace/drv/ohci/main.c
r7ab7c7f6 r62265ce 69 69 } 70 70 71 int ret = ohci_init(ohci, device);71 int ret = device_setup_ohci(device, ohci); 72 72 if (ret != EOK) { 73 73 usb_log_error("Failed to initialize OHCI driver: %s.\n", -
uspace/drv/ohci/ohci.c
r7ab7c7f6 r62265ce 127 127 * - registers interrupt handler 128 128 */ 129 int ohci_init(ohci_t *instance, ddf_dev_t *device)129 int device_setup_ohci(ddf_dev_t *device, ohci_t *instance) 130 130 { 131 131 assert(instance); 132 instance->hc_fun = NULL; 133 instance->rh_fun = NULL; 132 133 instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc"); 134 if (instance->hc_fun == NULL) { 135 usb_log_error("Failed to create HC function.\n"); 136 return ENOMEM; 137 } 138 instance->hc_fun->ops = &hc_ops; 139 instance->hc_fun->driver_data = &instance->hc; 140 141 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh"); 142 if (instance->rh_fun == NULL) { 143 ddf_fun_destroy(instance->hc_fun); 144 usb_log_error("Failed to create RH function.\n"); 145 return ENOMEM; 146 } 147 instance->rh_fun->ops = &rh_ops; 148 instance->rh_fun->driver_data = NULL; 149 134 150 #define CHECK_RET_DEST_FUN_RETURN(ret, message...) \ 135 151 if (ret != EOK) { \ 136 152 usb_log_error(message); \ 137 if (instance->hc_fun) \ 138 ddf_fun_destroy(instance->hc_fun); \ 139 if (instance->rh_fun) \ 140 ddf_fun_destroy(instance->rh_fun); \ 153 instance->hc_fun->ops = NULL; \ 154 instance->hc_fun->driver_data = NULL; \ 155 instance->rh_fun->ops = NULL; \ 156 instance->rh_fun->driver_data = NULL; \ 157 ddf_fun_destroy(instance->hc_fun); \ 158 ddf_fun_destroy(instance->rh_fun); \ 141 159 return ret; \ 142 160 } … … 156 174 bool interrupts = false; 157 175 #ifdef CONFIG_USBHC_NO_INTERRUPTS 158 usb_log_warning("Interrupts disabled in OS config, " \176 usb_log_warning("Interrupts disabled in OS config, " 159 177 "falling back to polling.\n"); 160 178 #else … … 163 181 usb_log_warning("Failed to enable interrupts: %s.\n", 164 182 str_error(ret)); 165 usb_log_info("HW interrupts not available, " \183 usb_log_info("HW interrupts not available, " 166 184 "falling back to polling.\n"); 167 185 } else { … … 171 189 #endif 172 190 173 instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc"); 174 ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 175 CHECK_RET_DEST_FUN_RETURN(ret, 176 "Failed(%d) to create HC function.\n", ret); 177 178 ret = hc_init(&instance->hc, instance->hc_fun, device, 179 mem_reg_base, mem_reg_size, interrupts); 191 ret = hc_init(&instance->hc, mem_reg_base, mem_reg_size, interrupts); 180 192 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init ohci-hcd.\n", ret); 181 instance->hc_fun->ops = &hc_ops;182 instance->hc_fun->driver_data = &instance->hc;183 ret = ddf_fun_bind(instance->hc_fun);184 CHECK_RET_DEST_FUN_RETURN(ret,185 "Failed(%d) to bind OHCI device function: %s.\n",186 ret, str_error(ret));187 #undef CHECK_RET_HC_RETURN188 193 189 194 #define CHECK_RET_FINI_RETURN(ret, message...) \ 190 195 if (ret != EOK) { \ 191 usb_log_error(message); \192 if (instance->hc_fun) \193 ddf_fun_destroy(instance->hc_fun); \194 if (instance->rh_fun) \195 ddf_fun_destroy(instance->rh_fun); \196 196 hc_fini(&instance->hc); \ 197 return ret; \197 CHECK_RET_DEST_FUN_RETURN(ret, message); \ 198 198 } 199 199 … … 204 204 "Failed(%d) to register interrupt handler.\n", ret); 205 205 206 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh"); 207 ret = (instance->rh_fun == NULL) ? ENOMEM : EOK; 206 ret = ddf_fun_bind(instance->hc_fun); 208 207 CHECK_RET_FINI_RETURN(ret, 209 "Failed(%d) to create root hub function.\n", ret); 210 211 212 instance->rh_fun->ops = &rh_ops; 213 instance->rh_fun->driver_data = NULL; 214 208 "Failed(%d) to bind OHCI device function: %s.\n", 209 ret, str_error(ret)); 210 215 211 device->driver_data = instance; 216 212 217 213 hc_start_hw(&instance->hc); 218 214 return EOK; 215 216 #undef CHECK_RET_DEST_FUN_RETURN 219 217 #undef CHECK_RET_FINI_RETURN 220 218 } -
uspace/drv/ohci/ohci.h
r7ab7c7f6 r62265ce 49 49 } ohci_t; 50 50 51 int ohci_init(ohci_t *instance, ddf_dev_t *device);51 int device_setup_ohci(ddf_dev_t *device, ohci_t *instance); 52 52 53 53 #endif
Note:
See TracChangeset
for help on using the changeset viewer.