Changes in uspace/drv/bus/usb/ohci/hc.c [0cd8089:8b54fe6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
r0cd8089 r8b54fe6 127 127 assert(hub_fun); 128 128 129 /* Try to get address 1 for root hub. */ 130 instance->rh.address = 1; 131 int ret = usb_device_manager_request_address( 132 &instance->generic.dev_manager, &instance->rh.address, false, 133 USB_SPEED_FULL); 134 if (ret != EOK) { 129 const usb_address_t hub_address = 130 usb_device_manager_get_free_address( 131 &instance->generic.dev_manager, USB_SPEED_FULL); 132 if (hub_address <= 0) { 135 133 usb_log_error("Failed to get OHCI root hub address: %s\n", 136 str_error(ret)); 137 return ret; 138 } 139 usb_device_manager_bind_address(&instance->generic.dev_manager, 140 instance->rh.address, hub_fun->handle); 134 str_error(hub_address)); 135 return hub_address; 136 } 137 instance->rh.address = hub_address; 138 usb_device_manager_bind( 139 &instance->generic.dev_manager, hub_address, hub_fun->handle); 141 140 142 141 #define CHECK_RET_UNREG_RETURN(ret, message...) \ 143 142 if (ret != EOK) { \ 144 143 usb_log_error(message); \ 145 usb_endpoint_manager_remove_ep( \ 146 &instance->generic.ep_manager, instance->rh.address, 0, \ 147 USB_DIRECTION_BOTH, NULL, NULL); \ 148 usb_device_manager_release_address( \ 149 &instance->generic.dev_manager, instance->rh.address); \ 144 usb_endpoint_manager_unregister_ep( \ 145 &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH);\ 146 usb_device_manager_release( \ 147 &instance->generic.dev_manager, hub_address); \ 150 148 return ret; \ 151 149 } else (void)0 152 ret = usb_endpoint_manager_add_ep( 153 &instance->generic.ep_manager, instance->rh.address, 0, 154 USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 155 0, NULL, NULL); 150 int ret = usb_endpoint_manager_add_ep( 151 &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH, 152 USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 0); 156 153 CHECK_RET_UNREG_RETURN(ret, 157 154 "Failed to register root hub control endpoint: %s.\n", … … 195 192 list_initialize(&instance->pending_batches); 196 193 197 hcd_init(&instance->generic, USB_SPEED_FULL, 198 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 194 ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11, 195 bandwidth_count_usb11); 196 CHECK_RET_RETURN(ret, "Failed to initialize generic driver: %s.\n", 197 str_error(ret)); 199 198 instance->generic.private_data = instance; 200 199 instance->generic.schedule = hc_schedule; 201 200 instance->generic.ep_add_hook = ohci_endpoint_init; 202 instance->generic.ep_remove_hook = ohci_endpoint_fini;203 201 204 202 ret = hc_init_memory(instance); … … 223 221 } 224 222 /*----------------------------------------------------------------------------*/ 225 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep) 226 { 227 assert(instance); 228 assert(ep); 229 223 void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep) 224 { 230 225 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 231 226 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 232 assert(list);233 assert(ohci_ep);234 235 227 /* Enqueue ep */ 236 228 switch (ep->transfer_type) { … … 255 247 } 256 248 /*----------------------------------------------------------------------------*/ 257 void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep) 258 { 259 assert(instance); 260 assert(ep); 261 249 void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep) 250 { 262 251 /* Dequeue ep */ 263 252 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 264 253 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 265 266 assert(list);267 assert(ohci_ep);268 254 switch (ep->transfer_type) { 269 255 case USB_TRANSFER_CONTROL: … … 579 565 580 566 /*Init HCCA */ 581 instance->hcca = hcca_get();567 instance->hcca = malloc32(sizeof(hcca_t)); 582 568 if (instance->hcca == NULL) 583 569 return ENOMEM; … … 585 571 usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca); 586 572 587 for (unsigned i = 0; i < 32; ++i) { 573 unsigned i = 0; 574 for (; i < 32; ++i) { 588 575 instance->hcca->int_ep[i] = 589 576 instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
Note:
See TracChangeset
for help on using the changeset viewer.