Date: Sun, 28 Jun 2009 11:47:39 GMT From: Sylvestre Gallon <syl@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165343 for review Message-ID: <200906281147.n5SBldL6003578@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165343 Change 165343 by syl@syl_atuin on 2009/06/28 11:47:24 - Update test3 transfer function. - move dprintf to a macro. - update libusb_proxy to use usb_handle_transfer_completion. - Add more transfer debug. Affected files ... .. //depot/projects/soc2009/syl_usb/libusb-tests/transfers/test3/test3.c#5 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#50 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.h#12 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_desc.c#17 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#18 edit Differences ... ==== //depot/projects/soc2009/syl_usb/libusb-tests/transfers/test3/test3.c#5 (text+ko) ==== @@ -52,14 +52,15 @@ #define EP_OUT 0x2 -void +int do_io(unsigned char ep, void *buff, uint32_t len, uint32_t timeout) { int transferred = 0; + int ret= 0; printf("do_io\n"); - libusb_bulk_transfer(devh, ep, buff, len, &transferred, timeout); - while(!transferred); + ret = libusb_bulk_transfer(devh, ep, buff, len, &transferred, timeout); + return ret; } void @@ -67,6 +68,7 @@ { umass_bbb_cbw_t cbw; umass_bbb_csw_t csw; + int ret = 0; printf("do_msc\n"); bzero(&cbw, sizeof(cbw)); @@ -80,11 +82,24 @@ cbw.bCDBLength = cmdlen; bcopy(pcmd, cbw.CBWCDB, cmdlen); - do_io(EP_OUT, &cbw, sizeof(cbw), 10000); + ret = do_io(EP_OUT, &cbw, sizeof(cbw), 10000); + if (ret != sizeof(cbw)) + printf("CBW write failed\n"); + if (datalen != 0) { do_io(EP_IN, buffer, datalen, 10000); } - do_io(EP_IN, &csw, sizeof(csw), 10000); + ret = do_io(EP_IN, &csw, sizeof(csw), 10000); + if (ret != sizeof(csw)) { + libusb_clear_halt(devh, EP_IN); + ret = do_io(EP_IN, &csw, sizeof(csw), 10000); + if (ret != sizeof(csw)) { + printf("Could not read CSW\n"); + return ; + } + + } + if (csw.bCSWStatus != 0) { printf("command (0x%02x) cursig=0x%08x failed\n", pcmd[0], cursig); } else { @@ -179,7 +194,7 @@ for (i = 0 ; i < BLOCK_SIZE ; i++) { if (i != 0 && (i % 0x10) == 0) printf("\n"); - printf("0.2x ", buffer[i]); + printf("0x%.2x ", buffer[i]); } printf("\n"); ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#50 (text+ko) ==== @@ -44,28 +44,6 @@ /* Library initialisation / deinitialisation */ -UNEXPORTED void -dprintf(libusb_context *ctx, int debug, char *str) -{ - if (ctx->debug != debug) - return ; - - switch (ctx->debug) { - case LIBUSB_DEBUG_NO: - break ; - case LIBUSB_DEBUG_FUNCTION: - printf("LIBUSB FUNCTION : %s\n", str); - break ; - case LIBUSB_DEBUG_TRANSFER: - printf("LIBUSB TRANSFER : %s\n", str); - break ; - default: - printf("LIBUSB UNKNOW DEBUG\n"); - break ; - } - return ; -} - void libusb_set_debug(libusb_context * ctx, int level) { @@ -144,7 +122,7 @@ { GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit enter"); usb_remove_pollfd(ctx, ctx->ctrl_pipe[0]); close(ctx->ctrl_pipe[0]); close(ctx->ctrl_pipe[1]); @@ -156,7 +134,7 @@ pthread_mutex_unlock(&default_context_lock); free(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_exit leave"); } /* Device handling and initialisation. */ @@ -171,7 +149,7 @@ int i; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list enter"); usb_backend = libusb20_be_alloc_default(); if (usb_backend == NULL) @@ -228,7 +206,7 @@ (*list)[i] = NULL; libusb20_be_free(usb_backend); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list leave"); return (i); } @@ -244,7 +222,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list enter"); if (list == NULL) return ; @@ -254,7 +232,7 @@ libusb_unref_device(list[i]); } free(list); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list leave"); } uint8_t @@ -264,11 +242,11 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number enter"); if (dev == NULL) return (LIBUSB_ERROR_NO_DEVICE); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number leave"); return (dev->bus_number); } @@ -279,11 +257,11 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address enter"); if (dev == NULL) return (LIBUSB_ERROR_NO_DEVICE); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address leave"); return (dev->device_address); } @@ -299,7 +277,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size enter"); if (dev == NULL) return (LIBUSB_ERROR_NO_DEVICE); @@ -324,7 +302,7 @@ out: libusb_free_config_descriptor(pdconf); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size leave"); return (ret); } @@ -335,7 +313,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device enter"); if (dev == NULL) return (NULL); @@ -344,7 +322,7 @@ dev->refcnt++; pthread_mutex_unlock(&dev->lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device leave"); return (dev); } @@ -355,7 +333,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device enter"); if (dev == NULL) return; @@ -372,7 +350,7 @@ libusb20_dev_free(dev->os_priv); free(dev); } - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device leave"); } int @@ -385,7 +363,7 @@ int err; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open enter"); dummy = 1; if (devh == NULL) @@ -439,7 +417,7 @@ pthread_mutex_unlock(&ctx->pollfd_modify_lock); libusb_unlock_events(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open leave"); return (0); } @@ -454,7 +432,7 @@ int i, j; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid enter"); devh = NULL; @@ -473,7 +451,7 @@ } libusb_free_device_list(devs, 1); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); return (devh); } @@ -492,7 +470,7 @@ pdev = devh->os_priv; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close enter"); pthread_mutex_lock(&ctx->pollfd_modify_lock); ctx->pollfd_modify++; @@ -532,7 +510,7 @@ pthread_mutex_unlock(&ctx->pollfd_modify_lock); libusb_unlock_events(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close leave"); } libusb_device * @@ -542,12 +520,12 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device enter"); if (devh == NULL) return (NULL); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device leave"); return (devh->dev); } @@ -558,7 +536,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration enter"); if (devh == NULL || config == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -566,7 +544,7 @@ *config = libusb20_dev_get_config_index((struct libusb20_device *) devh->dev->os_priv); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration leave"); return (0); } @@ -578,7 +556,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration enter"); if (devh == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -586,7 +564,7 @@ pdev = (struct libusb20_device *)devh->dev->os_priv; libusb20_dev_set_config_index(pdev, configuration); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration leave"); return (0); } @@ -598,7 +576,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface enter"); if (dev == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -614,7 +592,7 @@ dev->claimed_interfaces |= (1 << interface_number); pthread_mutex_unlock(&(dev->lock)); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface leave"); return (ret); } @@ -626,7 +604,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface enter"); ret = 0; if (dev == NULL) @@ -643,7 +621,7 @@ dev->claimed_interfaces &= ~(1 << interface_number); pthread_mutex_unlock(&(dev->lock)); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface leave"); return (ret); } @@ -656,7 +634,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting enter"); if (dev == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -675,7 +653,7 @@ alternate_setting) != 0) return (LIBUSB_ERROR_OTHER); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting leave"); return (0); } @@ -689,7 +667,7 @@ ctx = NULL; GET_CONTEXT(ctx); - 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, @@ -709,7 +687,7 @@ libusb20_tr_close(xfer); pthread_mutex_unlock(&libusb20_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt leave"); return (0); } @@ -720,13 +698,13 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device enter"); if (dev == NULL) return (LIBUSB20_ERROR_INVALID_PARAM); libusb20_dev_reset(dev->os_priv); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device leave"); return (0); } @@ -737,12 +715,12 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active enter"); if (devh == NULL) return (LIBUSB_ERROR_INVALID_PARAM); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active leave"); return (libusb20_dev_kernel_driver_active(devh->os_priv, interface)); } @@ -754,7 +732,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver enter"); if (devh == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -763,7 +741,7 @@ if (libusb20_dev_detach_kernel_driver(pdev, interface) == LIBUSB20_ERROR_OTHER) return (LIBUSB_ERROR_OTHER); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver leave"); return (0); } @@ -778,12 +756,12 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver enter"); if (devh == NULL) return (LIBUSB_ERROR_INVALID_PARAM); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver leave"); return (0); } @@ -799,7 +777,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer enter"); len = sizeof(struct libusb_transfer) + sizeof(struct usb_transfer) + @@ -815,7 +793,7 @@ xfer = (struct libusb_transfer *) ((uint8_t *)bxfer + sizeof(struct usb_transfer)); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer leave"); return (xfer); } @@ -827,7 +805,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer enter"); if (xfer == NULL) return ; @@ -836,7 +814,7 @@ sizeof(struct usb_transfer)); free(bxfer); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer leave"); return; } @@ -861,27 +839,25 @@ switch (status) { case LIBUSB20_TRANSFER_COMPLETED: - 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); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMIT"); + + usb_backend->transferred += libusb20_tr_get_actual_length(xfer); + usb_handle_transfer_completion(usb_backend, LIBUSB_TRANSFER_COMPLETED); + break ; case LIBUSB20_TRANSFER_START: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 START"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 START"); usb_xfer->actual_length = 0; switch (usb_xfer->type) { case LIBUSB_TRANSFER_TYPE_CONTROL: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE CTR"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE CTR"); libusb20_tr_setup_control(xfer, usb_xfer->buffer, (void *)(((uint8_t *) usb_xfer->buffer) + sizeof(libusb_control_setup)), usb_xfer->timeout); break ; case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE ISO"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE ISO"); iso_packets = libusb20_tr_get_max_frames(xfer); if (usb_xfer->num_iso_packets > iso_packets) usb_xfer->num_iso_packets = iso_packets; @@ -892,60 +868,54 @@ libusb20_tr_set_total_frames(xfer, i); break ; case LIBUSB_TRANSFER_TYPE_BULK: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE BULK"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE BULK"); libusb20_tr_setup_bulk(xfer, usb_xfer->buffer, usb_xfer->length, usb_xfer->timeout); break ; case LIBUSB_TRANSFER_TYPE_INTERRUPT: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE INTR"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "TYPE INTR"); libusb20_tr_setup_intr(xfer, usb_xfer->buffer, usb_xfer->length, usb_xfer->timeout); break ; } libusb20_tr_submit(xfer); - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMITED"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20 SUBMITED"); break ; default: - 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); break ; } switch (status) { case LIBUSB20_TRANSFER_COMPLETED: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS COMPLETED"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS COMPLETED"); usb_xfer->status = LIBUSB_TRANSFER_COMPLETED; break ; case LIBUSB20_TRANSFER_OVERFLOW: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR OVERFLOW"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR OVERFLOW"); usb_xfer->status = LIBUSB_TRANSFER_OVERFLOW; break ; case LIBUSB20_TRANSFER_NO_DEVICE: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR NO DEVICE"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR NO DEVICE"); usb_xfer->status = LIBUSB_TRANSFER_NO_DEVICE; break ; case LIBUSB20_TRANSFER_STALL: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR STALL"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR STALL"); usb_xfer->status = LIBUSB_TRANSFER_STALL; break ; case LIBUSB20_TRANSFER_CANCELLED: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR CANCELLED"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR CANCELLED"); usb_xfer->status = LIBUSB_TRANSFER_CANCELLED; break ; case LIBUSB20_TRANSFER_TIMED_OUT: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR TIMEOUT"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "STATUS TR TIMEOUT"); usb_xfer->status = LIBUSB_TRANSFER_TIMED_OUT; break ; case LIBUSB20_TRANSFER_ERROR: - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "ERROR"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "ERROR"); usb_xfer->status = LIBUSB_TRANSFER_ERROR; break ; } @@ -1054,7 +1024,7 @@ ctx = xfer->dev_handle->dev->ctx; pdev = xfer->dev_handle->os_priv; - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter"); usb_backend = (struct usb_transfer *) ((uint8_t *)xfer - sizeof(struct usb_transfer)); @@ -1135,13 +1105,14 @@ libusb20_tr_set_callback(usb20_xfer[1], libusb10_proxy); } + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20_TR_START"); libusb20_tr_start(usb20_xfer[0]); if (xfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) libusb20_tr_start(usb20_xfer[1]); pthread_mutex_unlock(&libusb20_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer leave"); return (0); } @@ -1152,7 +1123,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter"); if (xfer == NULL) return (LIBUSB_ERROR_NO_MEM); @@ -1161,7 +1132,7 @@ libusb20_tr_stop(xfer->os_priv); pthread_mutex_unlock(&libusb20_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer leave"); return (0); } ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.h#12 (text+ko) ==== @@ -89,7 +89,20 @@ uint8_t flags; }; -UNEXPORTED void dprintf(libusb_context *ctx, int debug, char *str); +#define DPRINTF(ctx, dbg, format, args...) \ +if (ctx->debug == dbg) { \ + printf("LIBUSB_%s : ", (ctx->debug == LIBUSB_DEBUG_FUNCTION) ? "FUNCTION" : "TRANSFER"); \ + switch(ctx->debug) { \ + case LIBUSB_DEBUG_FUNCTION: \ + printf(format, ## args);\ + break ; \ + case LIBUSB_DEBUG_TRANSFER: \ + printf(format, ## args);\ + break ; \ + } \ + printf("\n"); \ +} + UNEXPORTED int usb_add_pollfd(libusb_context *ctx, int fd, short events); UNEXPORTED void usb_remove_pollfd(libusb_context *ctx, int fd); UNEXPORTED void usb_handle_transfer_completion(struct usb_transfer *uxfer, ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_desc.c#17 (text+ko) ==== @@ -46,7 +46,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_descriptor enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_descriptor enter"); if ((dev == NULL) || (desc == NULL)) return (LIBUSB_ERROR_INVALID_PARAM); @@ -69,7 +69,7 @@ desc->iSerialNumber = pdesc->iSerialNumber; desc->bNumConfigurations = pdesc->bNumConfigurations; - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_descriptor leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_descriptor leave"); return (0); } @@ -83,12 +83,12 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_active_config_descriptor enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_active_config_descriptor enter"); pdev = dev->os_priv; idx = libusb20_dev_get_config_index(pdev); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_active_config_descriptor leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_active_config_descriptor leave"); return (libusb_get_config_descriptor(dev, idx, config)); } @@ -112,7 +112,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor enter"); if (dev == NULL || config == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -224,7 +224,7 @@ } free(pconf); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor leave"); return (0); } @@ -240,7 +240,7 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor_by_value enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor_by_value enter"); if (dev == NULL || config == NULL) return (LIBUSB_ERROR_INVALID_PARAM); @@ -258,7 +258,7 @@ free(pconf); } - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor_by_value leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor_by_value leave"); return (LIBUSB_ERROR_NOT_FOUND); } @@ -269,10 +269,10 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_config_descriptor enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_config_descriptor enter"); free(config); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_config_descriptor leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_config_descriptor leave"); } int @@ -285,13 +285,13 @@ ctx = NULL; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_string_descriptor_ascii enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_string_descriptor_ascii enter"); if (dev == NULL || data == NULL) return (LIBUSB20_ERROR_INVALID_PARAM); pdev = dev->os_priv; - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_string_descriptor_ascii leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_string_descriptor_ascii leave"); if (libusb20_dev_req_string_simple_sync(pdev, desc_index, data, length) == 0) return (strlen(data)); ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#18 (text+ko) ==== @@ -245,7 +245,7 @@ int i; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "handle_events enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "handle_events enter"); nfds = 0; i = -1; @@ -316,7 +316,7 @@ pthread_mutex_lock(&libusb20_lock); - dprintf(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20_PROCESS"); + DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "LIBUSB20_PROCESS"); ret = libusb20_dev_process(devh->os_priv); pthread_mutex_unlock(&libusb20_lock); @@ -333,7 +333,7 @@ handled: free(fds); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "handle_events leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "handle_events leave"); return ret; } @@ -345,7 +345,7 @@ int ret; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events enter"); pthread_mutex_lock(&ctx->pollfd_modify_lock); ret = ctx->pollfd_modify; @@ -361,7 +361,7 @@ ctx->event_handler_active = 1; - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events leave"); return (0); } @@ -369,19 +369,19 @@ libusb_lock_events(libusb_context * ctx) { GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events enter"); pthread_mutex_lock(&ctx->events_lock); ctx->event_handler_active = 1; - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events leave"); } void libusb_unlock_events(libusb_context * ctx) { GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events enter"); ctx->event_handler_active = 0; pthread_mutex_unlock(&ctx->events_lock); @@ -390,7 +390,7 @@ pthread_cond_broadcast(&ctx->event_waiters_cond); pthread_mutex_unlock(&ctx->event_waiters_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events leave"); } int @@ -399,7 +399,7 @@ int ret; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok enter"); pthread_mutex_lock(&ctx->pollfd_modify_lock); ret = ctx->pollfd_modify; @@ -408,7 +408,7 @@ if (ret != 0) return (0); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok leave"); return (1); } @@ -418,7 +418,7 @@ int ret; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active enter"); pthread_mutex_lock(&ctx->pollfd_modify_lock); ret = ctx->pollfd_modify; @@ -427,7 +427,7 @@ if (ret != 0) return (1); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active leave"); return (ctx->event_handler_active); } @@ -435,22 +435,22 @@ libusb_lock_event_waiters(libusb_context * ctx) { GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters enter"); pthread_mutex_lock(&ctx->event_waiters_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters leave"); } void libusb_unlock_event_waiters(libusb_context * ctx) { GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters enter"); pthread_mutex_unlock(&ctx->event_waiters_lock); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters leave"); } int @@ -460,7 +460,7 @@ struct timespec ts; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event enter"); if (tv == NULL) { pthread_cond_wait(&ctx->event_waiters_cond, @@ -485,7 +485,7 @@ if (ret == ETIMEDOUT) return (1); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event leave"); return (0); } @@ -497,7 +497,7 @@ int ret; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout enter"); ret = get_next_timeout(ctx, tv, &poll_timeout); if (ret != 0) { @@ -524,7 +524,7 @@ else if (ret == 1) return (handle_timeouts(ctx)); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout leave"); return (0); } @@ -535,13 +535,13 @@ int ret; GET_CONTEXT(ctx); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events enter"); tv.tv_sec = 2; tv.tv_usec = 0; ret = libusb_handle_events_timeout(ctx, &tv); - dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events leave"); return (ret); >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906281147.n5SBldL6003578>