Changeset 4deca9b in mainline for uspace/drv/ohci/hc.c


Ignore:
Timestamp:
2011-04-12T11:43:35Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
651b352
Parents:
1324ff3 (diff), 910ca3f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Extensive cleanup, preparation for OHCI rework

File:
1 edited

Legend:

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

    r1324ff3 r4deca9b  
    5555        assert(hub_fun);
    5656
     57        int ret;
     58
    5759        usb_address_t hub_address =
    5860            device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL);
     61        if (hub_address <= 0) {
     62                usb_log_error("Failed to get OHCI root hub address.\n");
     63                return hub_address;
     64        }
    5965        instance->rh.address = hub_address;
    6066        usb_device_keeper_bind(
    6167            &instance->manager, hub_address, hub_fun->handle);
    6268
    63         endpoint_t *ep = malloc(sizeof(endpoint_t));
    64         assert(ep);
    65         int ret = endpoint_init(ep, hub_address, 0, USB_DIRECTION_BOTH,
    66             USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64);
    67         assert(ret == EOK);
    68         ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, 0);
    69         assert(ret == EOK);
     69        ret = usb_endpoint_manager_add_ep(&instance->ep_manager,
     70            hub_address, 0, USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL,
     71            USB_SPEED_FULL, 64, 0);
     72        if (ret != EOK) {
     73                usb_log_error("Failed to add OHCI rh endpoint 0.\n");
     74                usb_device_keeper_release(&instance->manager, hub_address);
     75                return ret;
     76        }
    7077
    7178        char *match_str = NULL;
     79        /* DDF needs heap allocated string */
    7280        ret = asprintf(&match_str, "usb&class=hub");
    73 //      ret = (match_str == NULL) ? ret : EOK;
    7481        if (ret < 0) {
    7582                usb_log_error(
    7683                    "Failed(%d) to create root hub match-id string.\n", ret);
     84                usb_device_keeper_release(&instance->manager, hub_address);
    7785                return ret;
    7886        }
     
    8088        ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
    8189        if (ret != EOK) {
    82                 usb_log_error("Failed add create root hub match-id.\n");
     90                usb_log_error("Failed add root hub match-id.\n");
    8391        }
    8492        return ret;
     
    115123        fibril_mutex_initialize(&instance->guard);
    116124
    117         rh_init(&instance->rh, dev, instance->registers);
     125        rh_init(&instance->rh, instance->registers);
    118126
    119127        if (!interrupts) {
     
    130138        assert(instance);
    131139        assert(batch);
     140        assert(batch->ep);
    132141
    133142        /* check for root hub communication */
    134         if (batch->target.address == instance->rh.address) {
     143        if (batch->ep->address == instance->rh.address) {
    135144                return rh_request(&instance->rh, batch);
    136145        }
    137146
    138147        fibril_mutex_lock(&instance->guard);
    139         switch (batch->transfer_type) {
     148        switch (batch->ep->transfer_type) {
    140149        case USB_TRANSFER_CONTROL:
    141150                instance->registers->control &= ~C_CLE;
    142151                transfer_list_add_batch(
    143                     instance->transfers[batch->transfer_type], batch);
     152                    instance->transfers[batch->ep->transfer_type], batch);
    144153                instance->registers->command_status |= CS_CLF;
    145154                usb_log_debug2("Set CS control transfer filled: %x.\n",
     
    151160                instance->registers->control &= ~C_BLE;
    152161                transfer_list_add_batch(
    153                     instance->transfers[batch->transfer_type], batch);
     162                    instance->transfers[batch->ep->transfer_type], batch);
    154163                instance->registers->command_status |= CS_BLF;
    155164                usb_log_debug2("Set bulk transfer filled: %x.\n",
     
    161170                instance->registers->control &= (~C_PLE & ~C_IE);
    162171                transfer_list_add_batch(
    163                     instance->transfers[batch->transfer_type], batch);
     172                    instance->transfers[batch->ep->transfer_type], batch);
    164173                instance->registers->control |= C_PLE | C_IE;
    165174                usb_log_debug2("Added periodic transfer: %x.\n",
Note: See TracChangeset for help on using the changeset viewer.