Ignore:
File:
1 edited

Legend:

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

    r3ddbd38 rb77931d  
    5454
    5555/** Nesting pairs of standard descriptors. */
    56 static const usb_dp_descriptor_nesting_t descriptor_nesting[] = {
     56static usb_dp_descriptor_nesting_t descriptor_nesting[] = {
    5757        NESTING(CONFIGURATION, INTERFACE),
    5858        NESTING(INTERFACE, ENDPOINT),
     
    405405        }
    406406
     407#define TRY_LOOP(attempt_var) \
     408        for (attempt_var = 0; attempt_var < 3; attempt_var++)
     409
     410        size_t failed_attempts;
     411        int rc;
    407412
    408413        usb_pipe_start_long_transfer(pipe);
     
    410415        uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];
    411416        size_t transferred_size;
    412         int rc;
    413         for (size_t attempt_var = 0; attempt_var < 3; ++attempt_var) {
     417        TRY_LOOP(failed_attempts) {
    414418                rc = usb_request_get_descriptor(pipe, USB_REQUEST_TYPE_STANDARD,
    415419                    USB_REQUEST_RECIPIENT_DEVICE, USB_DESCTYPE_DEVICE,
     
    446450{
    447451        assert(pipe);
    448         assert(pipe->wire);
    449452        assert(hc_connection);
    450453
    451454        if (!usb_hc_connection_is_opened(hc_connection))
    452455                return EBADF;
     456
     457        const usb_target_t target =
     458            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
     459#define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff))
     460
    453461        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 
     462        int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     463            IPC_M_USBHC_REGISTER_ENDPOINT, target.packed,
     464            _PACK2(pipe->transfer_type, pipe->direction),
     465            _PACK2(pipe->max_packet_size, interval));
    460466        async_exchange_end(exch);
    461         return ret;
     467
     468#undef _PACK2
     469        return rc;
    462470}
    463471
     
    474482        assert(pipe->wire);
    475483        assert(hc_connection);
    476 
     484       
    477485        if (!usb_hc_connection_is_opened(hc_connection))
    478486                return EBADF;
    479 
     487       
    480488        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,
     489        int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     490            IPC_M_USBHC_UNREGISTER_ENDPOINT,
    484491            pipe->wire->address, pipe->endpoint_no, pipe->direction);
    485492        async_exchange_end(exch);
    486 
    487         return ret;
     493       
     494        return rc;
    488495}
    489496
Note: See TracChangeset for help on using the changeset viewer.