Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipesinit.c

    r277ff98 r3ddbd38  
    349349        fibril_mutex_initialize(&pipe->guard);
    350350        pipe->wire = connection;
     351        pipe->hc_sess = NULL;
     352        fibril_mutex_initialize(&pipe->hc_sess_mutex);
    351353        pipe->endpoint_no = endpoint_no;
    352354        pipe->transfer_type = transfer_type;
    353355        pipe->max_packet_size = max_packet_size;
    354356        pipe->direction = direction;
     357        pipe->refcount = 0;
     358        pipe->refcount_soft = 0;
    355359        pipe->auto_reset_halt = false;
    356360
     
    371375        assert(connection);
    372376
    373         int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL,
    374             CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH);
     377        int rc = usb_pipe_initialize(pipe, connection,
     378            0, USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE,
     379            USB_DIRECTION_BOTH);
    375380
    376381        pipe->auto_reset_halt = true;
     
    437442 * @return Error code.
    438443 */
    439 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval)
     444int usb_pipe_register(usb_pipe_t *pipe, unsigned interval,
     445    usb_hc_connection_t *hc_connection)
    440446{
    441447        assert(pipe);
    442448        assert(pipe->wire);
    443         assert(pipe->wire->hc_connection);
    444 
    445         return usb_hc_register_endpoint(pipe->wire->hc_connection,
    446            pipe->wire->address, pipe->endpoint_no, pipe->transfer_type,
    447            pipe->direction, pipe->max_packet_size, interval);
     449        assert(hc_connection);
     450
     451        if (!usb_hc_connection_is_opened(hc_connection))
     452                return EBADF;
     453        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
     454        if (!exch)
     455                return ENOMEM;
     456        const int ret = usbhc_register_endpoint(exch,
     457            pipe->wire->address, pipe->endpoint_no, pipe->transfer_type,
     458            pipe->direction, pipe->max_packet_size, interval);
     459
     460        async_exchange_end(exch);
     461        return ret;
    448462}
    449463
     
    454468 * @return Error code.
    455469 */
    456 int usb_pipe_unregister(usb_pipe_t *pipe)
     470int usb_pipe_unregister(usb_pipe_t *pipe,
     471    usb_hc_connection_t *hc_connection)
    457472{
    458473        assert(pipe);
    459474        assert(pipe->wire);
    460         assert(pipe->wire->hc_connection);
    461 
    462         return usb_hc_unregister_endpoint(pipe->wire->hc_connection,
     475        assert(hc_connection);
     476
     477        if (!usb_hc_connection_is_opened(hc_connection))
     478                return EBADF;
     479
     480        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
     481        if (!exch)
     482                return ENOMEM;
     483        const int ret = usbhc_unregister_endpoint(exch,
    463484            pipe->wire->address, pipe->endpoint_no, pipe->direction);
     485        async_exchange_end(exch);
     486
     487        return ret;
    464488}
    465489
Note: See TracChangeset for help on using the changeset viewer.