From d836b079b413e8cbd30267a741f09b6c6f44f378 Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Thu, 19 Nov 2009 12:06:05 -0800 Subject: [PATCH] arm-jtag-ew: use jtag_usb_open Rewrite armjtagwe_usb_open to use jtag_usb_open. --- src/jtag/arm-jtag-ew.c | 53 ++++++++++++++---------------------------- 1 file 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 +#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) -- 2.39.5