Deleted Added
full compact
1c1
< /* $FreeBSD: head/lib/libusb/libusb10.c 194676 2009-06-23 01:04:58Z thompsa $ */
---
> /* $FreeBSD: head/lib/libusb/libusb10.c 195560 2009-07-10 14:15:53Z thompsa $ */
78,79c78,79
< USB_LIST_INIT(&ctx->usb_devs);
< USB_LIST_INIT(&ctx->open_devs);
---
> TAILQ_INIT(&ctx->usb_devs);
> TAILQ_INIT(&ctx->open_devs);
88,89c88,89
< USB_LIST_INIT(&ctx->flying_transfers);
< USB_LIST_INIT(&ctx->pollfds);
---
> TAILQ_INIT(&ctx->flying_transfers);
> TAILQ_INIT(&ctx->pollfds);
126c126
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit enter");
138c138
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit leave");
153c153
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list enter");
180a181,184
> while (i != 0) {
> libusb_unref_device((*list)[i - 1]);
> i--;
> }
197c201
< LIST_ADD(&dev->list, &ctx->usb_devs);
---
> TAILQ_INSERT_HEAD(&ctx->usb_devs, dev, list);
206c210
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list leave");
222c226
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list enter");
232c236
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list leave");
242c246
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number enter");
246c250
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number leave");
257c261
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address enter");
261c265
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address leave");
277c281
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size enter");
302c306
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size leave");
313c317
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device enter");
322c326
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device leave");
333c337
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device enter");
344c348
< LIST_DEL(&dev->list);
---
> TAILQ_REMOVE(&ctx->usb_devs, dev, list);
350c354
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device leave");
363c367
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open enter");
380a385
> TAILQ_INIT(&hdl->ep_list);
393c398
< LIST_ADD(&hdl->list, &ctx->open_devs);
---
> TAILQ_INSERT_HEAD(&ctx->open_devs, hdl, list);
417c422
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open leave");
432c437
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid enter");
443c448
< pdesc->idProduct == product_id)
---
> pdesc->idProduct == product_id) {
445a451,452
> break ;
> }
449c456
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave");
457a465
> struct usb_ep_tr *eptr;
468c476
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close enter");
478c486
< LIST_DEL(&devh->list);
---
> TAILQ_REMOVE(&ctx->open_devs, devh, list);
482d489
< libusb_unref_device(devh->dev);
483a491,500
> libusb_unref_device(devh->dev);
> TAILQ_FOREACH(eptr, &devh->ep_list, list) {
> TAILQ_REMOVE(&devh->ep_list, eptr, list);
> libusb20_tr_close(((struct libusb20_transfer **)
> eptr->os_priv)[0]);
> if (eptr->flags)
> libusb20_tr_close(((struct libusb20_transfer **)
> eptr->os_priv)[1]);
> free((struct libusb20_transfer **)eptr->os_priv);
> }
495c512
< LIST_DEL(&devh->list);
---
> TAILQ_REMOVE(&ctx->open_devs, devh, list);
499d515
< libusb_unref_device(devh->dev);
500a517,526
> libusb_unref_device(devh->dev);
> TAILQ_FOREACH(eptr, &devh->ep_list, list) {
> TAILQ_REMOVE(&devh->ep_list, eptr, list);
> libusb20_tr_close(((struct libusb20_transfer **)
> eptr->os_priv)[0]);
> if (eptr->flags)
> libusb20_tr_close(((struct libusb20_transfer **)
> eptr->os_priv)[1]);
> free((struct libusb20_transfer **)eptr->os_priv);
> }
508c534
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close leave");
518c544
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device enter");
523c549
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device leave");
534c560
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration enter");
542c568
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration leave");
546,549d571
< /*
< * XXX this code is wrong. need update.
< */
<
558c580
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration enter");
565,567c587,588
< libusb20_dev_set_alt_index(pdev, libusb20_dev_get_config_index(pdev),
< configuration);
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration leave");
---
> libusb20_dev_set_config_index(pdev, configuration);
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration leave");
579c600
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface enter");
595c616
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface leave");
607c628
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface enter");
624c645
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface leave");
633d653
< int ret;
637c657
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting enter");
656c676
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting leave");
663a684
> struct libusb20_device *pdev;
669c690,696
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt enter");
>
> pdev = devh->os_priv;
> xfer = libusb20_tr_get_pointer(pdev,
> ((endpoint / 0x40) | (endpoint * 4)) % (16 * 4));
> if (xfer == NULL)
> return (LIBUSB_ERROR_NO_MEM);
671,672d697
< GET_XFER(xfer, endpoint, devh->os_priv);
<
685c710
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt leave");
696c721
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device enter");
702c727
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device leave");
713c738
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active enter");
718c743
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active leave");
730c755
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver enter");
739c764
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver leave");
754c779
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver enter");
759c784
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver leave");
775c800
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer enter");
791c816
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer leave");
803c828
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer enter");
812c837
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer leave");
815a841,915
> static int
> libusb_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer)
> {
> int ret;
> int usb_speed;
>
> usb_speed = libusb20_dev_get_speed(pdev);
>
> switch (xfer->type) {
> case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
> switch (usb_speed) {
> case LIBUSB20_SPEED_LOW:
> case LIBUSB20_SPEED_FULL:
> ret = 60 * 1;
> break ;
> default :
> ret = 60 * 8;
> break ;
> }
> break ;
> case LIBUSB_TRANSFER_TYPE_CONTROL:
> ret = 2;
> break ;
> default:
> ret = 1;
> break ;
> }
>
> return ret;
> }
>
> static int
> libusb_get_buffsize(struct libusb20_device *pdev, libusb_transfer *xfer)
> {
> int ret;
> int usb_speed;
>
> usb_speed = libusb20_dev_get_speed(pdev);
>
> switch (xfer->type) {
> case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
> ret = 0;
> break ;
> case LIBUSB_TRANSFER_TYPE_CONTROL:
> switch (usb_speed) {
> case LIBUSB20_SPEED_LOW:
> ret = 8;
> break ;
> case LIBUSB20_SPEED_FULL:
> ret = 64;
> break ;
> default:
> ret = 64;
> break ;
> }
> ret += 8;
> break ;
> default :
> switch (usb_speed) {
> case LIBUSB20_SPEED_LOW:
> ret = 256;
> break ;
> case LIBUSB20_SPEED_FULL:
> ret = 4096;
> break ;
> default:
> ret = 16384;
> break ;
> }
> break ;
> }
>
> return ret;
> }
>
822a923,925
> uint32_t pos;
> uint32_t max;
> uint32_t size;
837,843c940,948
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMIT");
< usb_xfer->actual_length += libusb20_tr_get_actual_length(xfer);
< usb_xfer->callback(usb_xfer);
<
< pthread_mutex_lock(&ctx->flying_transfers_lock);
< LIST_DEL(&usb_backend->list);
< pthread_mutex_unlock(&ctx->flying_transfers_lock);
---
> usb_backend->transferred += libusb20_tr_get_actual_length(xfer);
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 TRANSFER %i bytes",
> usb_backend->transferred);
> if (usb_backend->transferred != usb_xfer->length)
> goto tr_start;
>
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 TRANSFER COMPLETE");
> usb_handle_transfer_completion(usb_backend, LIBUSB_TRANSFER_COMPLETED);
>
846c951,956
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 START");
---
> tr_start:
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 START");
> max = libusb_get_buffsize(pdev, usb_xfer);
> pos = usb_backend->transferred;
> size = (usb_xfer->length - pos);
> size = (size > max) ? max : size;
850c960
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE CTR");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE CTR");
852c962
< (void *)(((uint8_t *) usb_xfer->buffer) +
---
> (void *)(((uint8_t *) &usb_xfer->buffer[pos]) +
857c967
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE ISO");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE ISO");
863c973
< usb_xfer->buffer, usb_xfer->length, i);
---
> &usb_xfer->buffer[pos], size, i);
868,870c978,980
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE BULK");
< libusb20_tr_setup_bulk(xfer, usb_xfer->buffer,
< usb_xfer->length, usb_xfer->timeout);
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE BULK");
> libusb20_tr_setup_bulk(xfer, &usb_xfer->buffer[pos],
> size, usb_xfer->timeout);
873,875c983,985
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE INTR");
< libusb20_tr_setup_intr(xfer, usb_xfer->buffer,
< usb_xfer->length, usb_xfer->timeout);
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE INTR");
> libusb20_tr_setup_intr(xfer, &usb_xfer->buffer[pos],
> size, usb_xfer->timeout);
879c989
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMITED");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMITED");
882,891c992,995
< if (ctx->debug == LIBUSB_DEBUG_TRANSFER)
< printf("LIBUSB TRANSFER DEFAULT 0x%x\n", status);
< usb_xfer->actual_length = 0;
< usb_xfer->status = LIBUSB_TRANSFER_CANCELLED;
<
< pthread_mutex_lock(&ctx->flying_transfers_lock);
< LIST_DEL(&usb_backend->list);
< pthread_mutex_unlock(&ctx->flying_transfers_lock);
< usb_xfer->callback(usb_xfer);
<
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TRANSFER DEFAULT 0x%x\n",
> status);
> usb_backend->transferred = 0;
> usb_handle_transfer_completion(usb_backend, LIBUSB_TRANSFER_CANCELLED);
897c1001
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS COMPLETED");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS COMPLETED");
901c1005
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR OVERFLOW");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR OVERFLOW");
905c1009
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR NO DEVICE");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR NO DEVICE");
909c1013
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR STALL");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR STALL");
913c1017
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR CANCELLED");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR CANCELLED");
917c1021
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR TIMEOUT");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR TIMEOUT");
921c1025
< dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "ERROR");
---
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "ERROR");
927,1002d1030
< static int
< libusb_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer)
< {
< int ret;
< int usb_speed;
<
< usb_speed = libusb20_dev_get_speed(pdev);
<
< switch (xfer->type) {
< case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
< switch (usb_speed) {
< case LIBUSB20_SPEED_LOW:
< case LIBUSB20_SPEED_FULL:
< ret = 60 * 1;
< break ;
< default :
< ret = 60 * 8;
< break ;
< }
< break ;
< case LIBUSB_TRANSFER_TYPE_CONTROL:
< ret = 2;
< break ;
< default:
< ret = 1;
< break ;
< }
<
< return ret;
< }
<
< static int
< libusb_get_buffsize(struct libusb20_device *pdev, libusb_transfer *xfer)
< {
< int ret;
< int usb_speed;
<
< usb_speed = libusb20_dev_get_speed(pdev);
<
< switch (xfer->type) {
< case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
< ret = 0;
< break ;
< case LIBUSB_TRANSFER_TYPE_CONTROL:
< switch (usb_speed) {
< case LIBUSB20_SPEED_LOW:
< ret = 8;
< break ;
< case LIBUSB20_SPEED_FULL:
< ret = 64;
< break ;
< case LIBUSB20_SPEED_HIGH:
< ret = 64;
< break ;
< }
< /*add */
< ret += 8;
< break ;
< default :
< switch (usb_speed) {
< case LIBUSB20_SPEED_LOW:
< ret = 256;
< break ;
< case LIBUSB20_SPEED_FULL:
< ret = 4096;
< break ;
< default:
< ret = 16384;
< break ;
< }
< break ;
< }
<
< return ret;
< }
<
1010c1038
< struct libusb_context *ctx;
---
> struct usb_ep_tr *eptr;
1012a1041,1042
> libusb_device_handle *devh;
> libusb_context *ctx;
1015d1044
< int num_frame;
1018d1046
< int i;
1028a1057
> devh = xfer->dev_handle;
1030c1059
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter");
1048c1077
< }
---
> }
1052,1053c1081,1082
< if (USB_LIST_EMPTY(&ctx->flying_transfers)) {
< LIST_ADD(&usb_backend->list, &ctx->flying_transfers);
---
> if (TAILQ_EMPTY(&ctx->flying_transfers)) {
> TAILQ_INSERT_HEAD(&ctx->flying_transfers, usb_backend, list);
1057c1086
< LIST_ADD_TAIL(&usb_backend->list, &ctx->flying_transfers);
---
> TAILQ_INSERT_HEAD(&ctx->flying_transfers, usb_backend, list);
1060c1089
< LIST_FOREACH_ENTRY(usb_node, &ctx->flying_transfers, list) {
---
> TAILQ_FOREACH(usb_node, &ctx->flying_transfers, list) {
1066c1095
< LIST_ADD_TAIL(&usb_backend->list, &usb_node->list);
---
> TAILQ_INSERT_TAIL(&ctx->flying_transfers, usb_backend, list);
1070c1099
< LIST_ADD_TAIL(&usb_backend->list, &ctx->flying_transfers);
---
> TAILQ_INSERT_TAIL(&ctx->flying_transfers, usb_backend, list);
1075,1078c1104,1106
< usb20_xfer[0] = libusb20_tr_get_pointer(pdev,
< ((xfer->endpoint / 0x40) | (xfer->endpoint * 4)) % (16 * 4));
< usb20_xfer[1] = libusb20_tr_get_pointer(pdev,
< (((xfer->endpoint / 0x40) | (xfer->endpoint * 4)) % (16 * 4)) + 1);
---
> ep_idx = (xfer->endpoint / 0x40) | (xfer->endpoint * 4) % (16 * 4);
> usb20_xfer[0] = libusb20_tr_get_pointer(pdev, ep_idx);
> usb20_xfer[1] = libusb20_tr_get_pointer(pdev, ep_idx + 1);
1090,1094c1118,1134
< ret = libusb20_tr_open(usb20_xfer[0], buffsize,
< maxframe, xfer->endpoint);
< if (xfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)
< ret |= libusb20_tr_open(usb20_xfer[1], buffsize,
< maxframe, xfer->endpoint);
---
> ret = 0;
> TAILQ_FOREACH(eptr, &devh->ep_list, list) {
> if (xfer->endpoint == eptr->addr)
> ret++;
> }
> if (ret == 0) {
> eptr = malloc(sizeof(struct usb_ep_tr));
> eptr->addr = xfer->endpoint;
> eptr->idx = ep_idx;
> eptr->os_priv = usb20_xfer;
> eptr->flags = (xfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)?1:0;
> TAILQ_INSERT_HEAD(&devh->ep_list, eptr, list);
> ret = libusb20_tr_open(usb20_xfer[0], buffsize,
> maxframe, xfer->endpoint);
> if (xfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)
> ret |= libusb20_tr_open(usb20_xfer[1], buffsize,
> maxframe, xfer->endpoint);
1096,1101c1136,1142
< if (ret != 0) {
< pthread_mutex_unlock(&libusb20_lock);
< pthread_mutex_lock(&ctx->flying_transfers_lock);
< LIST_DEL(&usb_backend->list);
< pthread_mutex_unlock(&ctx->flying_transfers_lock);
< return (LIBUSB_ERROR_OTHER);
---
> if (ret != 0) {
> pthread_mutex_unlock(&libusb20_lock);
> pthread_mutex_lock(&ctx->flying_transfers_lock);
> TAILQ_REMOVE(&ctx->flying_transfers, usb_backend, list);
> pthread_mutex_unlock(&ctx->flying_transfers_lock);
> return (LIBUSB_ERROR_OTHER);
> }
1110a1152
> DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20_TR_START");
1117c1159
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer leave");
1128c1170
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter");
1137c1179
< dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer leave");
---
> DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer leave");