Changeset 22ecbde in mainline


Ignore:
Timestamp:
2011-12-14T15:24:30Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6e3c005
Parents:
bdb23c63
Message:

libusbdev: Cleanup. Remove redundant functions.

File:
1 edited

Legend:

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

    rbdb23c63 r22ecbde  
    4040/** Prepare pipe for a long transfer.
    4141 *
    42  * By a long transfer is mean transfer consisting of several
    43  * requests to the HC.
    44  * Calling such function is optional and it has positive effect of
     42 * Long transfer is transfer consisting of several requests to the HC.
     43 * Calling this function is optional and it has positive effect of
    4544 * improved performance because IPC session is initiated only once.
    4645 *
     
    5756/*----------------------------------------------------------------------------*/
    5857/** Terminate a long transfer on a pipe.
    59  *
     58 * @param pipe Pipe where to end the long transfer.
     59 * @return Error code.
    6060 * @see usb_pipe_start_long_transfer
    61  *
    62  * @param pipe Pipe where to end the long transfer.
    6361 */
    6462int usb_pipe_end_long_transfer(usb_pipe_t *pipe)
     
    7068}
    7169/*----------------------------------------------------------------------------*/
    72 /** Request an in transfer, no checking of input parameters.
    73  *
    74  * @param[in] pipe Pipe used for the transfer.
    75  * @param[out] buffer Buffer where to store the data.
    76  * @param[in] size Size of the buffer (in bytes).
    77  * @param[out] size_transfered Number of bytes that were actually transfered.
    78  * @return Error code.
    79  */
    80 static int usb_pipe_read_no_check(usb_pipe_t *pipe, uint64_t setup,
    81     void *buffer, size_t size, size_t *size_transfered)
    82 {
    83         /* Isochronous transfer are not supported (yet) */
    84         if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
    85             pipe->transfer_type != USB_TRANSFER_BULK &&
    86             pipe->transfer_type != USB_TRANSFER_CONTROL)
    87             return ENOTSUP;
    88 
    89         return usb_device_control_read(pipe->wire,
    90             pipe->endpoint_no, setup, buffer, size, size_transfered);
    91 }
    92 /*----------------------------------------------------------------------------*/
    93 /** Request an out transfer, no checking of input parameters.
    94  *
    95  * @param[in] pipe Pipe used for the transfer.
    96  * @param[in] buffer Buffer with data to transfer.
    97  * @param[in] size Size of the buffer (in bytes).
    98  * @return Error code.
    99  */
    100 static int usb_pipe_write_no_check(usb_pipe_t *pipe, uint64_t setup,
    101     const void *buffer, size_t size)
    102 {
    103         /* Only interrupt and bulk transfers are supported */
    104         if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
    105             pipe->transfer_type != USB_TRANSFER_BULK &&
    106             pipe->transfer_type != USB_TRANSFER_CONTROL)
    107             return ENOTSUP;
    108 
    109         return usb_device_control_write(pipe->wire,
    110             pipe->endpoint_no, setup, buffer, size);
    111 }
    112 /*----------------------------------------------------------------------------*/
    11370/** Try to clear endpoint halt of default control pipe.
    11471 *
     
    12279                return;
    12380        }
    124 
    12581
    12682        /* Prevent infinite recursion. */
     
    145101int usb_pipe_control_read(usb_pipe_t *pipe,
    146102    const void *setup_buffer, size_t setup_buffer_size,
    147     void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
     103    void *buffer, size_t buffer_size, size_t *transfered_size)
    148104{
    149105        assert(pipe);
     
    153109        }
    154110
    155         if ((data_buffer == NULL) || (data_buffer_size == 0)) {
     111        if ((buffer == NULL) || (buffer_size == 0)) {
    156112                return EINVAL;
    157113        }
     
    162118        }
    163119
     120        /* Isochronous transfer are not supported (yet) */
     121        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     122            pipe->transfer_type != USB_TRANSFER_BULK &&
     123            pipe->transfer_type != USB_TRANSFER_CONTROL)
     124            return ENOTSUP;
     125
    164126        uint64_t setup_packet;
    165127        memcpy(&setup_packet, setup_buffer, 8);
    166128
    167129        size_t act_size = 0;
    168         const int rc = usb_pipe_read_no_check(pipe, setup_packet,
    169             data_buffer, data_buffer_size, &act_size);
     130        const int rc = usb_device_control_read(pipe->wire,
     131            pipe->endpoint_no, setup_packet, buffer, buffer_size, &act_size);
    170132
    171133        if (rc == ESTALL) {
     
    173135        }
    174136
    175         if (rc == EOK && data_transfered_size != NULL) {
    176                 *data_transfered_size = act_size;
     137        if (rc == EOK && transfered_size != NULL) {
     138                *transfered_size = act_size;
    177139        }
    178140
     
    193155int usb_pipe_control_write(usb_pipe_t *pipe,
    194156    const void *setup_buffer, size_t setup_buffer_size,
    195     const void *data_buffer, size_t data_buffer_size)
     157    const void *buffer, size_t buffer_size)
    196158{
    197159        assert(pipe);
     
    201163        }
    202164
    203         if ((data_buffer == NULL) && (data_buffer_size > 0)) {
    204                 return EINVAL;
    205         }
    206 
    207         if ((data_buffer != NULL) && (data_buffer_size == 0)) {
     165        if ((buffer == NULL) && (buffer_size > 0)) {
     166                return EINVAL;
     167        }
     168
     169        if ((buffer != NULL) && (buffer_size == 0)) {
    208170                return EINVAL;
    209171        }
     
    214176        }
    215177
     178        /* Isochronous transfer are not supported (yet) */
     179        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     180            pipe->transfer_type != USB_TRANSFER_BULK &&
     181            pipe->transfer_type != USB_TRANSFER_CONTROL)
     182            return ENOTSUP;
     183
    216184        uint64_t setup_packet;
    217185        memcpy(&setup_packet, setup_buffer, 8);
    218186
    219         const int rc = usb_pipe_write_no_check(pipe, setup_packet,
    220             data_buffer, data_buffer_size);
     187        const int rc = usb_device_control_write(pipe->wire,
     188            pipe->endpoint_no, setup_packet, buffer, buffer_size);
    221189
    222190        if (rc == ESTALL) {
     
    256224        }
    257225
     226        /* Isochronous transfer are not supported (yet) */
     227        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     228            pipe->transfer_type != USB_TRANSFER_BULK &&
     229            pipe->transfer_type != USB_TRANSFER_CONTROL)
     230            return ENOTSUP;
     231
    258232        size_t act_size = 0;
    259         const int rc = usb_pipe_read_no_check(pipe, 0, buffer, size, &act_size);
    260 
     233        const int rc = usb_device_read(pipe->wire,
     234            pipe->endpoint_no, buffer, size, &act_size);
    261235
    262236        if (rc == EOK && size_transfered != NULL) {
     
    290264        }
    291265
    292         return usb_pipe_write_no_check(pipe, 0, buffer, size);
     266        /* Isochronous transfer are not supported (yet) */
     267        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     268            pipe->transfer_type != USB_TRANSFER_BULK &&
     269            pipe->transfer_type != USB_TRANSFER_CONTROL)
     270            return ENOTSUP;
     271
     272        return usb_device_write(pipe->wire,
     273            pipe->endpoint_no, buffer, size);
    293274}
    294275/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.