Changeset 02fc5c4 in mainline for uspace/lib/usbdev/src/pipesinit.c


Ignore:
Timestamp:
2011-11-25T17:41:23Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
095bddfc
Parents:
56bdd9a4
Message:

usbhc: Export IPC wrapper instead of IPC call numbers.

Hide IPC protocol in one file, instead of multiple client implementations.
Rename 'find_by_address' ⇒ 'get_handle'

File:
1 edited

Legend:

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

    r56bdd9a4 r02fc5c4  
    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;
    412407
    413408        usb_pipe_start_long_transfer(pipe);
     
    415410        uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];
    416411        size_t transferred_size;
    417         TRY_LOOP(failed_attempts) {
     412        int rc;
     413        for (size_t attempt_var = 0; attempt_var < 3; ++attempt_var) {
    418414                rc = usb_request_get_descriptor(pipe, USB_REQUEST_TYPE_STANDARD,
    419415                    USB_REQUEST_RECIPIENT_DEVICE, USB_DESCTYPE_DEVICE,
     
    450446{
    451447        assert(pipe);
     448        assert(pipe->wire);
    452449        assert(hc_connection);
    453450
    454451        if (!usb_hc_connection_is_opened(hc_connection))
    455452                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 
    461453        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    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));
     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
    466460        async_exchange_end(exch);
    467 
    468 #undef _PACK2
    469         return rc;
     461        return ret;
    470462}
    471463
     
    482474        assert(pipe->wire);
    483475        assert(hc_connection);
    484        
     476
    485477        if (!usb_hc_connection_is_opened(hc_connection))
    486478                return EBADF;
    487        
     479
    488480        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    489         int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    490             IPC_M_USBHC_UNREGISTER_ENDPOINT,
     481        if (!exch)
     482                return ENOMEM;
     483        const int ret = usbhc_unregister_endpoint(exch,
    491484            pipe->wire->address, pipe->endpoint_no, pipe->direction);
    492485        async_exchange_end(exch);
    493        
    494         return rc;
     486
     487        return ret;
    495488}
    496489
Note: See TracChangeset for help on using the changeset viewer.