Ignore:
Timestamp:
2012-06-29T13:02:14Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
722912e
Parents:
ba72f2b (diff), 0bbd13e (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

Trivial conflicts.

File:
1 edited

Legend:

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

    rba72f2b r6843a9c  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/** @addtogroup libusbhost
    2930 * @{
     
    3233 * USB transfer transaction structures.
    3334 */
     35
    3436#ifndef LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
    3537#define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
     
    4345#define USB_SETUP_PACKET_SIZE 8
    4446
    45 typedef struct usb_transfer_batch usb_transfer_batch_t;
    4647/** Structure stores additional data needed for communication with EP */
    47 struct usb_transfer_batch {
     48typedef struct usb_transfer_batch {
    4849        /** Endpoint used for communication */
    4950        endpoint_t *ep;
     
    6667         */
    6768        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;
    7269        /** Host controller function, passed to callback function */
    7370        ddf_fun_t *fun;
     71
     72        /** Actually used portion of the buffer
     73         * This member is never accessed by functions provided in this header,
     74         * with the exception of usb_transfer_batch_finish. For external use.
     75         */
     76        size_t transfered_size;
     77        /** Indicates success/failure of the communication
     78         * This member is never accessed by functions provided in this header,
     79         * with the exception of usb_transfer_batch_finish. For external use.
     80         */
     81        int error;
    7482
    7583        /** Driver specific data */
     
    7785        /** Callback to properly remove driver data during destruction */
    7886        void (*private_data_dtor)(void *p_data);
    79 };
     87} usb_transfer_batch_t;
    8088
    8189/** Printf formatting string for dumping usb_transfer_batch_t. */
     
    93101
    94102
    95 usb_transfer_batch_t * usb_transfer_batch_get(
     103usb_transfer_batch_t * usb_transfer_batch_create(
    96104    endpoint_t *ep,
    97105    char *buffer,
     
    105113    void (*private_data_dtor)(void *p_data)
    106114);
     115void usb_transfer_batch_destroy(const usb_transfer_batch_t *instance);
    107116
    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);
     117void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     118    const void* data, size_t size, int error);
    113119
    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 }
    125 /*----------------------------------------------------------------------------*/
    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.
     120/** Finish batch using stored error value and transferred size.
    139121 *
    140122 * @param[in] instance Batch structure to use.
    141123 * @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.
    144124 */
    145 static inline void usb_transfer_batch_finish_error(
    146     usb_transfer_batch_t *instance, const void* data, size_t size, int error)
     125static inline void usb_transfer_batch_finish(
     126    const usb_transfer_batch_t *instance, const void* data)
    147127{
    148128        assert(instance);
    149         instance->error = error;
    150         usb_transfer_batch_finish(instance, data, size);
     129        usb_transfer_batch_finish_error(
     130            instance, data, instance->transfered_size, instance->error);
    151131}
    152 /*----------------------------------------------------------------------------*/
    153 /** Helper function, determines batch direction absed on the present callbacks
    154  * @param[in] instance Batch structure to use.
     132
     133/** Determine batch direction based on the callbacks present
     134 * @param[in] instance Batch structure to use, non-null.
    155135 * @return USB_DIRECTION_IN, or USB_DIRECTION_OUT.
    156136 */
     
    175155        assert(false);
    176156}
     157
    177158#endif
     159
    178160/**
    179161 * @}
Note: See TracChangeset for help on using the changeset viewer.