Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3f0ad85a in mainline


Ignore:
Timestamp:
2011-11-26T13:52:35Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
3ddbd38
Parents:
8969f46
Message:

libusbdev: Reorder functions in pipesio.c

File:
1 edited

Legend:

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

    r8969f46 r3f0ad85a  
    9393}
    9494
    95 /** Request a read (in) transfer on an endpoint pipe.
    96  *
    97  * @param[in] pipe Pipe used for the transfer.
    98  * @param[out] buffer Buffer where to store the data.
    99  * @param[in] size Size of the buffer (in bytes).
    100  * @param[out] size_transfered Number of bytes that were actually transfered.
    101  * @return Error code.
    102  */
    103 int usb_pipe_read(usb_pipe_t *pipe,
    104     void *buffer, size_t size, size_t *size_transfered)
    105 {
    106         assert(pipe);
    107 
    108         if (buffer == NULL) {
    109                 return EINVAL;
    110         }
    111 
    112         if (size == 0) {
    113                 return EINVAL;
    114         }
    115 
    116         if (pipe->direction != USB_DIRECTION_IN) {
    117                 return EBADF;
    118         }
    119 
    120         if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
    121                 return EBADF;
    122         }
    123 
    124         size_t act_size = 0;
    125         const int rc = usb_pipe_read_no_check(pipe, 0, buffer, size, &act_size);
    126 
    127 
    128         if (rc == EOK && size_transfered != NULL) {
    129                 *size_transfered = act_size;
    130         }
    131 
    132         return rc;
    133 }
    134 
    13595/** Request an out transfer, no checking of input parameters.
    13696 *
     
    170130}
    171131
    172 /** Request a write (out) transfer on an endpoint pipe.
    173  *
    174  * @param[in] pipe Pipe used for the transfer.
    175  * @param[in] buffer Buffer with data to transfer.
    176  * @param[in] size Size of the buffer (in bytes).
    177  * @return Error code.
    178  */
    179 int usb_pipe_write(usb_pipe_t *pipe, const void *buffer, size_t size)
    180 {
    181         assert(pipe);
    182 
    183         if (buffer == NULL || size == 0) {
    184                 return EINVAL;
    185         }
    186 
    187         if (pipe->direction != USB_DIRECTION_OUT) {
    188                 return EBADF;
    189         }
    190 
    191         if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
    192                 return EBADF;
    193         }
    194 
    195         return usb_pipe_write_no_check(pipe, 0, buffer, size);
    196 }
    197 
    198132/** Try to clear endpoint halt of default control pipe.
    199133 *
     
    311245        return rc;
    312246}
     247
     248/** Request a read (in) transfer on an endpoint pipe.
     249 *
     250 * @param[in] pipe Pipe used for the transfer.
     251 * @param[out] buffer Buffer where to store the data.
     252 * @param[in] size Size of the buffer (in bytes).
     253 * @param[out] size_transfered Number of bytes that were actually transfered.
     254 * @return Error code.
     255 */
     256int usb_pipe_read(usb_pipe_t *pipe,
     257    void *buffer, size_t size, size_t *size_transfered)
     258{
     259        assert(pipe);
     260
     261        if (buffer == NULL) {
     262                return EINVAL;
     263        }
     264
     265        if (size == 0) {
     266                return EINVAL;
     267        }
     268
     269        if (pipe->direction != USB_DIRECTION_IN) {
     270                return EBADF;
     271        }
     272
     273        if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
     274                return EBADF;
     275        }
     276
     277        size_t act_size = 0;
     278        const int rc = usb_pipe_read_no_check(pipe, 0, buffer, size, &act_size);
     279
     280
     281        if (rc == EOK && size_transfered != NULL) {
     282                *size_transfered = act_size;
     283        }
     284
     285        return rc;
     286}
     287
     288/** Request a write (out) transfer on an endpoint pipe.
     289 *
     290 * @param[in] pipe Pipe used for the transfer.
     291 * @param[in] buffer Buffer with data to transfer.
     292 * @param[in] size Size of the buffer (in bytes).
     293 * @return Error code.
     294 */
     295int usb_pipe_write(usb_pipe_t *pipe, const void *buffer, size_t size)
     296{
     297        assert(pipe);
     298
     299        if (buffer == NULL || size == 0) {
     300                return EINVAL;
     301        }
     302
     303        if (pipe->direction != USB_DIRECTION_OUT) {
     304                return EBADF;
     305        }
     306
     307        if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
     308                return EBADF;
     309        }
     310
     311        return usb_pipe_write_no_check(pipe, 0, buffer, size);
     312}
     313
    313314/**
    314315 * @}
Note: See TracChangeset for help on using the changeset viewer.