Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r0cd8089 r8b54fe6  
    127127        assert(hub_fun);
    128128
    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) {
    135133                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);
    141140
    142141#define CHECK_RET_UNREG_RETURN(ret, message...) \
    143142if (ret != EOK) { \
    144143        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); \
    150148        return ret; \
    151149} 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);
    156153        CHECK_RET_UNREG_RETURN(ret,
    157154            "Failed to register root hub control endpoint: %s.\n",
     
    195192        list_initialize(&instance->pending_batches);
    196193
    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));
    199198        instance->generic.private_data = instance;
    200199        instance->generic.schedule = hc_schedule;
    201200        instance->generic.ep_add_hook = ohci_endpoint_init;
    202         instance->generic.ep_remove_hook = ohci_endpoint_fini;
    203201
    204202        ret = hc_init_memory(instance);
     
    223221}
    224222/*----------------------------------------------------------------------------*/
    225 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
    226 {
    227         assert(instance);
    228         assert(ep);
    229 
     223void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep)
     224{
    230225        endpoint_list_t *list = &instance->lists[ep->transfer_type];
    231226        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    232         assert(list);
    233         assert(ohci_ep);
    234 
    235227        /* Enqueue ep */
    236228        switch (ep->transfer_type) {
     
    255247}
    256248/*----------------------------------------------------------------------------*/
    257 void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep)
    258 {
    259         assert(instance);
    260         assert(ep);
    261 
     249void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep)
     250{
    262251        /* Dequeue ep */
    263252        endpoint_list_t *list = &instance->lists[ep->transfer_type];
    264253        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    265 
    266         assert(list);
    267         assert(ohci_ep);
    268254        switch (ep->transfer_type) {
    269255        case USB_TRANSFER_CONTROL:
     
    579565
    580566        /*Init HCCA */
    581         instance->hcca = hcca_get();
     567        instance->hcca = malloc32(sizeof(hcca_t));
    582568        if (instance->hcca == NULL)
    583569                return ENOMEM;
     
    585571        usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
    586572
    587         for (unsigned i = 0; i < 32; ++i) {
     573        unsigned i = 0;
     574        for (; i < 32; ++i) {
    588575                instance->hcca->int_ep[i] =
    589576                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
Note: See TracChangeset for help on using the changeset viewer.