Changes in uspace/drv/vhc/transfer.c [e913cc9:beee81a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/transfer.c
re913cc9 rbeee81a 161 161 } 162 162 163 static vhc_transfer_t *dequeue_first_transfer(vhc_virtdev_t *dev)164 {165 assert(fibril_mutex_is_locked(&dev->guard));166 assert(!list_empty(&dev->transfer_queue));167 168 vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next,169 vhc_transfer_t, link);170 list_remove(&transfer->link);171 172 return transfer;173 }174 175 176 static void execute_transfer_callback_and_free(vhc_transfer_t *transfer,177 size_t data_transfer_size, int outcome)178 {179 assert(outcome != ENAK);180 181 usb_log_debug2("Transfer %p ended: %s.\n",182 transfer, str_error(outcome));183 184 if (transfer->direction == USB_DIRECTION_IN) {185 transfer->callback_in(transfer->ddf_fun, outcome,186 data_transfer_size, transfer->callback_arg);187 } else {188 assert(transfer->direction == USB_DIRECTION_OUT);189 transfer->callback_out(transfer->ddf_fun, outcome,190 transfer->callback_arg);191 }192 193 free(transfer);194 }195 163 196 164 int vhc_transfer_queue_processor(void *arg) … … 206 174 } 207 175 208 vhc_transfer_t *transfer = dequeue_first_transfer(dev); 176 vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next, 177 vhc_transfer_t, link); 178 list_remove(&transfer->link); 209 179 fibril_mutex_unlock(&dev->guard); 210 180 … … 244 214 245 215 if (rc != ENAK) { 246 execute_transfer_callback_and_free(transfer, 247 data_transfer_size, rc); 216 usb_log_debug2("Transfer %p ended: %s.\n", 217 transfer, str_error(rc)); 218 if (transfer->direction == USB_DIRECTION_IN) { 219 transfer->callback_in(transfer->ddf_fun, rc, 220 data_transfer_size, transfer->callback_arg); 221 } else { 222 assert(transfer->direction == USB_DIRECTION_OUT); 223 transfer->callback_out(transfer->ddf_fun, rc, 224 transfer->callback_arg); 225 } 226 free(transfer); 248 227 } 249 228 … … 252 231 } 253 232 254 /* Immediately fail all remaining transfers. */255 while (!list_empty(&dev->transfer_queue)) {256 vhc_transfer_t *transfer = dequeue_first_transfer(dev);257 execute_transfer_callback_and_free(transfer, 0, EBADCHECKSUM);258 }259 260 233 fibril_mutex_unlock(&dev->guard); 261 234 235 // TODO - destroy pending transfers 236 262 237 return EOK; 263 238 }
Note:
See TracChangeset
for help on using the changeset viewer.