Changes in uspace/lib/usb/src/host/batch.c [2cc6e97:96b8f322] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/batch.c
r2cc6e97 r96b8f322 39 39 #include <usb/host/batch.h> 40 40 41 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);42 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);43 44 41 void usb_transfer_batch_init( 45 42 usb_transfer_batch_t *instance, 46 endpoint_t *ep, 43 usb_target_t target, 44 usb_transfer_type_t transfer_type, 45 usb_speed_t speed, 46 size_t max_packet_size, 47 47 char *buffer, 48 char * data_buffer,48 char *transport_buffer, 49 49 size_t buffer_size, 50 50 char *setup_buffer, … … 54 54 void *arg, 55 55 ddf_fun_t *fun, 56 void *private_data,57 void (*private_data_dtor)(void *p_data)56 endpoint_t *ep, 57 void *private_data 58 58 ) 59 59 { 60 60 assert(instance); 61 61 link_initialize(&instance->link); 62 instance->ep = ep; 62 instance->target = target; 63 instance->transfer_type = transfer_type; 64 instance->speed = speed; 65 instance->direction = ep->direction; 63 66 instance->callback_in = func_in; 64 67 instance->callback_out = func_out; 65 68 instance->arg = arg; 66 69 instance->buffer = buffer; 67 instance-> data_buffer = data_buffer;70 instance->transport_buffer = transport_buffer; 68 71 instance->buffer_size = buffer_size; 69 72 instance->setup_buffer = setup_buffer; 70 73 instance->setup_size = setup_size; 74 instance->max_packet_size = max_packet_size; 71 75 instance->fun = fun; 72 76 instance->private_data = private_data; 73 instance->private_data_dtor = private_data_dtor;74 77 instance->transfered_size = 0; 75 78 instance->next_step = NULL; 76 79 instance->error = EOK; 80 instance->ep = ep; 77 81 endpoint_use(instance->ep); 78 }79 /*----------------------------------------------------------------------------*/80 /** Helper function, calls callback and correctly destroys batch structure.81 *82 * @param[in] instance Batch structure to use.83 */84 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance)85 {86 assert(instance);87 usb_transfer_batch_call_in(instance);88 usb_transfer_batch_dispose(instance);89 }90 /*----------------------------------------------------------------------------*/91 /** Helper function calls callback and correctly destroys batch structure.92 *93 * @param[in] instance Batch structure to use.94 */95 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance)96 {97 assert(instance);98 usb_transfer_batch_call_out(instance);99 usb_transfer_batch_dispose(instance);100 82 } 101 83 /*----------------------------------------------------------------------------*/ … … 123 105 assert(instance); 124 106 assert(instance->callback_in); 125 assert(instance->ep);126 107 127 108 /* We are data in, we need data */ 128 memcpy(instance->buffer, instance->data_buffer, instance->buffer_size); 109 memcpy(instance->buffer, instance->transport_buffer, 110 instance->buffer_size); 129 111 130 112 usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n", 131 instance, instance->ep->address, instance->ep->endpoint, 132 usb_str_speed(instance->ep->speed), 133 usb_str_transfer_type_short(instance->ep->transfer_type), 134 instance->transfered_size, str_error(instance->error), instance->error); 113 instance, 114 instance->target.address, instance->target.endpoint, 115 usb_str_speed(instance->speed), 116 usb_str_transfer_type_short(instance->transfer_type), 117 instance->transfered_size, 118 str_error(instance->error), instance->error); 135 119 136 120 instance->callback_in(instance->fun, instance->error, … … 148 132 149 133 usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n", 150 instance, instance->ep->address, instance->ep->endpoint, 151 usb_str_speed(instance->ep->speed), 152 usb_str_transfer_type_short(instance->ep->transfer_type), 134 instance, 135 instance->target.address, instance->target.endpoint, 136 usb_str_speed(instance->speed), 137 usb_str_transfer_type_short(instance->transfer_type), 153 138 str_error(instance->error), instance->error); 154 139 … … 156 141 instance->error, instance->arg); 157 142 } 158 /*----------------------------------------------------------------------------*/159 /** Correctly dispose all used data structures.160 *161 * @param[in] instance Batch structure to use.162 */163 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance)164 {165 assert(instance);166 usb_log_debug("Batch(%p) disposing.\n", instance);167 if (instance->private_data) {168 assert(instance->private_data_dtor);169 instance->private_data_dtor(instance->private_data);170 }171 free(instance);172 }173 143 /** 174 144 * @}
Note:
See TracChangeset
for help on using the changeset viewer.