From 45e5fc89799ca28b4aae89cca5de813f0611980f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Aug 2010 22:03:20 +0000 Subject: [PATCH] update vsllink to libusb-1 api git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1843 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 6 ++++++ urjtag/src/tap/cable/vsllink.c | 7 +++---- urjtag/src/tap/usbconn/libusb.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index aeb7e7ca..8196de61 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -24,6 +24,12 @@ * src/svf/svf_bison.y: Avoid further overhead by using memcpy() with all known lengths rather than strcpy(). + * src/tap/cable/vsllink.c (vsllink_init): Convert libusb-0.x API to newer + libusb-1.x API. + * src/tap/usbconn/libusb.h: Glue a few more libusb-0.x API defines to newer + libusb-1.x API defines. Add errors for some libusb-0.x API functions to + catch problems in the future. + 2010-08-26 Mike Frysinger * src/tap/cable/gpio.c: Rewrite to use raw file descriptors when working with diff --git a/urjtag/src/tap/cable/vsllink.c b/urjtag/src/tap/cable/vsllink.c index 247597e4..b92225c2 100644 --- a/urjtag/src/tap/cable/vsllink.c +++ b/urjtag/src/tap/cable/vsllink.c @@ -270,10 +270,9 @@ vsllink_init (urj_cable_t *cable) } /* disable cdc device */ - result = usb_control_msg (params->handle, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE, - 0, 0, 0, NULL, 0, - VERSALOON_USB_TIMEOUT); + result = libusb_control_transfer (params->handle, + LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_INTERFACE, + 0, 0, 0, NULL, 0, VERSALOON_USB_TIMEOUT); if (result < 0) { urj_log (URJ_LOG_LEVEL_ERROR, _("fail to disable cdc in Versaloon\n")); diff --git a/urjtag/src/tap/usbconn/libusb.h b/urjtag/src/tap/usbconn/libusb.h index 636021c3..61a428a9 100644 --- a/urjtag/src/tap/usbconn/libusb.h +++ b/urjtag/src/tap/usbconn/libusb.h @@ -36,6 +36,16 @@ # define LIBUSB_ENDPOINT_IN USB_ENDPOINT_IN +# define LIBUSB_REQUEST_TYPE_STANDARD USB_TYPE_STANDARD +# define LIBUSB_REQUEST_TYPE_CLASS USB_TYPE_CLASS +# define LIBUSB_REQUEST_TYPE_VENDOR USB_TYPE_VENDOR +# define LIBUSB_REQUEST_TYPE_RESERVED USB_TYPE_RESERVED + +# define LIBUSB_RECIPIENT_DEVICE USB_RECIP_DEVICE +# define LIBUSB_RECIPIENT_INTERFACE USB_RECIP_INTERFACE +# define LIBUSB_RECIPIENT_ENDPOINT USB_RECIP_ENDPOINT +# define LIBUSB_RECIPIENT_OTHER USB_RECIP_OTHER + # define libusb_device usb_device # define libusb_device_handle usb_dev_handle # define libusb_device_descriptor usb_device_descriptor @@ -71,6 +81,8 @@ libusb_bulk_transfer (libusb_device_handle *dev_handle, unsigned char endpoint, return 0; } } +# define usb_bulk_read(...) use_libusb_1_api +# define usb_bulk_write(...) use_libusb_1_api static inline int libusb_control_transfer (libusb_device_handle *dev_handle, uint8_t request_type, @@ -88,6 +100,7 @@ libusb_control_transfer (libusb_device_handle *dev_handle, uint8_t request_type, else return ret; } +# define usb_control_msg(...) use_libusb_1_api static inline int libusb_open (struct libusb_device *dev, libusb_device_handle **handle) @@ -95,6 +108,7 @@ libusb_open (struct libusb_device *dev, libusb_device_handle **handle) *handle = usb_open (dev); return *handle ? 0 : -99; } +# define usb_open(...) use_libusb_1_api static inline int libusb_get_string_descriptor_ascii (libusb_device_handle *dev, uint8_t index, @@ -102,6 +116,7 @@ libusb_get_string_descriptor_ascii (libusb_device_handle *dev, uint8_t index, { return usb_get_string_simple (dev, index, (char *) data, length); } +# define usb_get_string_simple(...) use_libusb_1_api #endif