Changeset db96017 in mainline for uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
- Timestamp:
- 2012-04-07T17:41:44Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
rb69e4c0 rdb96017 43 43 #define USB_SETUP_PACKET_SIZE 8 44 44 45 typedef struct usb_transfer_batch usb_transfer_batch_t;46 45 /** Structure stores additional data needed for communication with EP */ 47 struct usb_transfer_batch {46 typedef struct usb_transfer_batch { 48 47 /** Endpoint used for communication */ 49 48 endpoint_t *ep; … … 66 65 */ 67 66 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;72 67 /** Host controller function, passed to callback function */ 73 68 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; 74 80 75 81 /** Driver specific data */ … … 77 83 /** Callback to properly remove driver data during destruction */ 78 84 void (*private_data_dtor)(void *p_data); 79 } ;85 } usb_transfer_batch_t; 80 86 81 87 /** Printf formatting string for dumping usb_transfer_batch_t. */ … … 93 99 94 100 95 usb_transfer_batch_t * usb_transfer_batch_ get(101 usb_transfer_batch_t * usb_transfer_batch_create( 96 102 endpoint_t *ep, 97 103 char *buffer, … … 105 111 void (*private_data_dtor)(void *p_data) 106 112 ); 113 void usb_transfer_batch_destroy(const usb_transfer_batch_t *instance); 107 114 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 } 115 void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance, 116 const void* data, size_t size, int error); 125 117 /*----------------------------------------------------------------------------*/ 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. 139 119 * 140 120 * @param[in] instance Batch structure to use. 141 121 * @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.144 122 */ 145 static inline void usb_transfer_batch_finish _error(146 usb_transfer_batch_t *instance, const void* data, size_t size, int error)123 static inline void usb_transfer_batch_finish( 124 const usb_transfer_batch_t *instance, const void* data) 147 125 { 148 126 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); 151 129 } 152 130 /*----------------------------------------------------------------------------*/ 153 /** Helper function, determines batch direction absed on the present callbacks154 * @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. 155 133 * @return USB_DIRECTION_IN, or USB_DIRECTION_OUT. 156 134 */
Note:
See TracChangeset
for help on using the changeset viewer.
