diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-19 12:06:05 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-24 07:30:19 -0800 |
commit | d836b079b413e8cbd30267a741f09b6c6f44f378 (patch) | |
tree | fa28421b4223454506ef175383a4e7c1af3e40c8 | |
parent | 3a660e229301c905392a0b2826e5ebf08c4e01b9 (diff) | |
download | openocd_libswd-d836b079b413e8cbd30267a741f09b6c6f44f378.tar.gz openocd_libswd-d836b079b413e8cbd30267a741f09b6c6f44f378.tar.bz2 openocd_libswd-d836b079b413e8cbd30267a741f09b6c6f44f378.tar.xz openocd_libswd-d836b079b413e8cbd30267a741f09b6c6f44f378.zip |
arm-jtag-ew: use jtag_usb_open
Rewrite armjtagwe_usb_open to use jtag_usb_open.
-rw-r--r-- | src/jtag/arm-jtag-ew.c | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/src/jtag/arm-jtag-ew.c b/src/jtag/arm-jtag-ew.c index 46dacc6d..01c5559f 100644 --- a/src/jtag/arm-jtag-ew.c +++ b/src/jtag/arm-jtag-ew.c @@ -25,6 +25,7 @@ #include "interface.h" #include "commands.h" #include <usb.h> +#include "usb_common.h" #define USB_VID 0x15ba @@ -714,50 +715,30 @@ static int armjtagew_tap_execute(void) static struct armjtagew* armjtagew_usb_open() { - struct usb_bus *busses; - struct usb_bus *bus; - struct usb_device *dev; - - struct armjtagew *result; - - result = (struct armjtagew*) malloc(sizeof(struct armjtagew)); - usb_init(); - usb_find_busses(); - usb_find_devices(); - - busses = usb_get_busses(); - /* find armjtagew device in usb bus */ + const uint16_t vids[] = { USB_VID, 0 }; + const uint16_t pids[] = { USB_PID, 0 }; + struct usb_dev_handle *dev; + if (jtag_usb_open(vids, pids, &dev) != ERROR_OK) + return NULL; - for (bus = busses; bus; bus = bus->next) - { - for (dev = bus->devices; dev; dev = dev->next) - { - if ((dev->descriptor.idVendor == USB_VID) && (dev->descriptor.idProduct == USB_PID)) - { - result->usb_handle = usb_open(dev); + struct armjtagew *result = malloc(sizeof(struct armjtagew)); + result->usb_handle = dev; #if 0 - /* usb_set_configuration required under win32 */ - usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue); + /* usb_set_configuration required under win32 */ + usb_set_configuration(dev, dev->config[0].bConfigurationValue); #endif - usb_claim_interface(result->usb_handle, 0); - + usb_claim_interface(dev, 0); #if 0 - /* - * This makes problems under Mac OS X. And is not needed - * under Windows. Hopefully this will not break a linux build - */ - usb_set_altinterface(result->usb_handle, 0); + /* + * This makes problems under Mac OS X. And is not needed + * under Windows. Hopefully this will not break a linux build + */ + usb_set_altinterface(dev, 0); #endif - return result; - } - } - } - - free(result); - return NULL; + return result; } static void armjtagew_usb_close(struct armjtagew *armjtagew) |