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