Ignore:
File:
1 edited

Legend:

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

    r8b54fe6 r0cd8089  
    127127        assert(hub_fun);
    128128
    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) {
    133135                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);
    140141
    141142#define CHECK_RET_UNREG_RETURN(ret, message...) \
    142143if (ret != EOK) { \
    143144        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); \
    148150        return ret; \
    149151} 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);
    153156        CHECK_RET_UNREG_RETURN(ret,
    154157            "Failed to register root hub control endpoint: %s.\n",
     
    192195        list_initialize(&instance->pending_batches);
    193196
    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);
    198199        instance->generic.private_data = instance;
    199200        instance->generic.schedule = hc_schedule;
    200201        instance->generic.ep_add_hook = ohci_endpoint_init;
     202        instance->generic.ep_remove_hook = ohci_endpoint_fini;
    201203
    202204        ret = hc_init_memory(instance);
     
    221223}
    222224/*----------------------------------------------------------------------------*/
    223 void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep)
    224 {
     225void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
     226{
     227        assert(instance);
     228        assert(ep);
     229
    225230        endpoint_list_t *list = &instance->lists[ep->transfer_type];
    226231        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
     232        assert(list);
     233        assert(ohci_ep);
     234
    227235        /* Enqueue ep */
    228236        switch (ep->transfer_type) {
     
    247255}
    248256/*----------------------------------------------------------------------------*/
    249 void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep)
    250 {
     257void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep)
     258{
     259        assert(instance);
     260        assert(ep);
     261
    251262        /* Dequeue ep */
    252263        endpoint_list_t *list = &instance->lists[ep->transfer_type];
    253264        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
     265
     266        assert(list);
     267        assert(ohci_ep);
    254268        switch (ep->transfer_type) {
    255269        case USB_TRANSFER_CONTROL:
     
    565579
    566580        /*Init HCCA */
    567         instance->hcca = malloc32(sizeof(hcca_t));
     581        instance->hcca = hcca_get();
    568582        if (instance->hcca == NULL)
    569583                return ENOMEM;
     
    571585        usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
    572586
    573         unsigned i = 0;
    574         for (; i < 32; ++i) {
     587        for (unsigned i = 0; i < 32; ++i) {
    575588                instance->hcca->int_ep[i] =
    576589                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa;
Note: See TracChangeset for help on using the changeset viewer.