Ignore:
Timestamp:
2012-04-07T17:41:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b6913b7
Parents:
b69e4c0 (diff), 6bb169b5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    rb69e4c0 rdb96017  
    4343#define USB_SETUP_PACKET_SIZE 8
    4444
    45 typedef struct usb_transfer_batch usb_transfer_batch_t;
    4645/** Structure stores additional data needed for communication with EP */
    47 struct usb_transfer_batch {
     46typedef struct usb_transfer_batch {
    4847        /** Endpoint used for communication */
    4948        endpoint_t *ep;
     
    6665         */
    6766        size_t setup_size;
    68         /** Actually used portion of the buffer */
    69         size_t transfered_size;
    70         /** Indicates success/failure of the communication */
    71         int error;
    7267        /** Host controller function, passed to callback function */
    7368        ddf_fun_t *fun;
     69
     70        /** Actually used portion of the buffer
     71         * This member is never accessed by functions provided in this header,
     72         * with the exception of usb_transfer_batch_finish. For external use.
     73         */
     74        size_t transfered_size;
     75        /** Indicates success/failure of the communication
     76         * This member is never accessed by functions provided in this header,
     77         * with the exception of usb_transfer_batch_finish. For external use.
     78         */
     79        int error;
    7480
    7581        /** Driver specific data */
     
    7783        /** Callback to properly remove driver data during destruction */
    7884        void (*private_data_dtor)(void *p_data);
    79 };
     85} usb_transfer_batch_t;
    8086
    8187/** Printf formatting string for dumping usb_transfer_batch_t. */
     
    9399
    94100
    95 usb_transfer_batch_t * usb_transfer_batch_get(
     101usb_transfer_batch_t * usb_transfer_batch_create(
    96102    endpoint_t *ep,
    97103    char *buffer,
     
    105111    void (*private_data_dtor)(void *p_data)
    106112);
     113void usb_transfer_batch_destroy(const usb_transfer_batch_t *instance);
    107114
    108 void usb_transfer_batch_finish(usb_transfer_batch_t *instance,
    109     const void* data, size_t size);
    110 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
    111 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
    112 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance);
    113 
    114 /** Helper function, calls callback and correctly destroys batch structure.
    115  *
    116  * @param[in] instance Batch structure to use.
    117  */
    118 static inline void usb_transfer_batch_call_in_and_dispose(
    119     usb_transfer_batch_t *instance)
    120 {
    121         assert(instance);
    122         usb_transfer_batch_call_in(instance);
    123         usb_transfer_batch_dispose(instance);
    124 }
     115void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     116    const void* data, size_t size, int error);
    125117/*----------------------------------------------------------------------------*/
    126 /** Helper function calls callback and correctly destroys batch structure.
    127  *
    128  * @param[in] instance Batch structure to use.
    129  */
    130 static inline void usb_transfer_batch_call_out_and_dispose(
    131     usb_transfer_batch_t *instance)
    132 {
    133         assert(instance);
    134         usb_transfer_batch_call_out(instance);
    135         usb_transfer_batch_dispose(instance);
    136 }
    137 /*----------------------------------------------------------------------------*/
    138 /** Helper function, sets error value and finishes transfer.
     118/** Finish batch using stored error value and transferred size.
    139119 *
    140120 * @param[in] instance Batch structure to use.
    141121 * @param[in] data Data to copy to the output buffer.
    142  * @param[in] size Size of @p data.
    143  * @param[in] error Set batch status to this error value.
    144122 */
    145 static inline void usb_transfer_batch_finish_error(
    146     usb_transfer_batch_t *instance, const void* data, size_t size, int error)
     123static inline void usb_transfer_batch_finish(
     124    const usb_transfer_batch_t *instance, const void* data)
    147125{
    148126        assert(instance);
    149         instance->error = error;
    150         usb_transfer_batch_finish(instance, data, size);
     127        usb_transfer_batch_finish_error(
     128            instance, data, instance->transfered_size, instance->error);
    151129}
    152130/*----------------------------------------------------------------------------*/
    153 /** Helper function, determines batch direction absed on the present callbacks
    154  * @param[in] instance Batch structure to use.
     131/** Determine batch direction based on the callbacks present
     132 * @param[in] instance Batch structure to use, non-null.
    155133 * @return USB_DIRECTION_IN, or USB_DIRECTION_OUT.
    156134 */
Note: See TracChangeset for help on using the changeset viewer.