Ignore:
File:
1 edited

Legend:

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

    r592369ae ra19a2d7  
    5555
    5656        size_t res_bw;
    57         endpoint_t *ep = hc_get_endpoint(*hc,
     57        endpoint_t *ep = usb_endpoint_manager_get_ep(&(*hc)->ep_manager,
    5858            target.address, target.endpoint, direction, &res_bw);
    5959        if (ep == NULL) {
     
    6363        }
    6464
    65         usb_log_debug("%s %d:%d %zu(%zu).\n",
    66             name, target.address, target.endpoint, size, ep->max_packet_size);
    67 
    6865        const size_t bw = bandwidth_count_usb11(
    6966            ep->speed, ep->transfer_type, size, ep->max_packet_size);
     
    7168                usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
    7269                    "but only %zu is reserved.\n",
    73                     target.address, target.endpoint, name, bw, res_bw);
     70                    name, target.address, target.endpoint, bw, res_bw);
    7471                return ENOSPC;
    7572        }
     73        usb_log_debug("%s %d:%d %zu(%zu).\n",
     74            name, target.address, target.endpoint, size, ep->max_packet_size);
    7675
    7776        *batch = batch_get(
     
    158157        hc_t *hc = fun_to_hc(fun);
    159158        assert(hc);
    160 
     159        if (address == hc->rh.address)
     160                return EOK;
    161161        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address);
    162162        if (speed >= USB_SPEED_MAX) {
    163163                speed = ep_speed;
    164164        }
    165         const size_t size = max_packet_size;
     165        const size_t size =
     166            (transfer_type == USB_TRANSFER_INTERRUPT
     167            || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?
     168            max_packet_size : 0;
     169        int ret;
     170
     171        endpoint_t *ep = malloc(sizeof(endpoint_t));
     172        if (ep == NULL)
     173                return ENOMEM;
     174        ret = endpoint_init(ep, address, endpoint, direction,
     175            transfer_type, speed, max_packet_size);
     176        if (ret != EOK) {
     177                free(ep);
     178                return ret;
     179        }
    166180
    167181        usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
     
    169183            usb_str_speed(speed), direction, size, max_packet_size, interval);
    170184
    171         return hc_add_endpoint(hc, address, endpoint, speed, transfer_type,
    172             direction, max_packet_size, size, interval);
     185        ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size);
     186        if (ret != EOK) {
     187                endpoint_destroy(ep);
     188        }
     189        return ret;
    173190}
    174191/*----------------------------------------------------------------------------*/
     
    181198        usb_log_debug("Unregister endpoint %d:%d %d.\n",
    182199            address, endpoint, direction);
    183         return hc_remove_endpoint(hc, address, endpoint, direction);
     200        return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
     201            endpoint, direction);
    184202}
    185203/*----------------------------------------------------------------------------*/
     
    213231        ret = hc_schedule(hc, batch);
    214232        if (ret != EOK) {
    215                 usb_transfer_batch_dispose(batch);
     233                batch_dispose(batch);
    216234        }
    217235        return ret;
     
    247265        ret = hc_schedule(hc, batch);
    248266        if (ret != EOK) {
    249                 usb_transfer_batch_dispose(batch);
     267                batch_dispose(batch);
    250268        }
    251269        return ret;
     
    281299        ret = hc_schedule(hc, batch);
    282300        if (ret != EOK) {
    283                 usb_transfer_batch_dispose(batch);
     301                batch_dispose(batch);
    284302        }
    285303        return ret;
     
    315333        ret = hc_schedule(hc, batch);
    316334        if (ret != EOK) {
    317                 usb_transfer_batch_dispose(batch);
     335                batch_dispose(batch);
    318336        }
    319337        return ret;
     
    331349 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
    332350 *      and deallocated by the caller).
    333  * @param[in] setup_size Size of @p setup_packet buffer in bytes.
     351 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
    334352 * @param[in] data_buffer Data buffer (in USB endianess, allocated and
    335353 *      deallocated by the caller).
    336  * @param[in] size Size of @p data_buffer buffer in bytes.
     354 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
    337355 * @param[in] callback Callback to be issued once the transfer is complete.
    338356 * @param[in] arg Pass-through argument to the callback.
     
    355373        ret = hc_schedule(hc, batch);
    356374        if (ret != EOK) {
    357                 usb_transfer_batch_dispose(batch);
     375                batch_dispose(batch);
    358376        }
    359377        return ret;
     
    371389 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
    372390 *      and deallocated by the caller).
    373  * @param[in] setup_size Size of @p setup_packet buffer in bytes.
     391 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
    374392 * @param[in] data_buffer Buffer where to store the data (in USB endianess,
    375393 *      allocated and deallocated by the caller).
    376  * @param[in] size Size of @p data_buffer buffer in bytes.
     394 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
    377395 * @param[in] callback Callback to be issued once the transfer is complete.
    378396 * @param[in] arg Pass-through argument to the callback.
     
    394412        ret = hc_schedule(hc, batch);
    395413        if (ret != EOK) {
    396                 usb_transfer_batch_dispose(batch);
     414                batch_dispose(batch);
    397415        }
    398416        return ret;
Note: See TracChangeset for help on using the changeset viewer.