From e863ac34f19afe1574a4555734cd383d0382b8a1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 10 May 2011 23:01:41 +0000 Subject: [PATCH] ft2232: set interface for libftdi Properly set the interface to be used for libftdi variant of the ft2232 driver. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1905 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 5 +++++ urjtag/src/tap/usbconn/libftdi.c | 26 ++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 0c886436..171fc50f 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,8 @@ +2011-05-10 Mike Frysinger + + * src/tap/usbconn/libftdi.c (usbconn_ftdi_common_open): Use the new interface + option and call ftdi_set_interface with it. Patch by Michael Walle. + 2011-04-30 Mike Frysinger * configure.ac: Force recent versions of autotools (at least ones released diff --git a/urjtag/src/tap/usbconn/libftdi.c b/urjtag/src/tap/usbconn/libftdi.c index 5232452a..4a676291 100644 --- a/urjtag/src/tap/usbconn/libftdi.c +++ b/urjtag/src/tap/usbconn/libftdi.c @@ -359,6 +359,17 @@ usbconn_ftdi_common_open (urj_usbconn_t *conn, urj_log_level_t ll) struct ftdi_context *fc = p->fc; int status; + /* Keep same interface numbers as in libftd2xx, where the index is zero + based. In libfdti, 0 is a special 'ANY' interface. */ + status = ftdi_set_interface (fc, p->interface + 1); + if (status < 0) + { + urj_error_set (URJ_ERROR_FTD, + _("%s(): ftdi_set_interface() failed: %s"), + __func__, ftdi_get_error_string (fc)); + goto open_error; + } + /* use command line string for desc= as serial number and try to open a matching device */ status = ftdi_usb_open_desc (fc, p->vid, p->pid, NULL, p->serial); @@ -374,15 +385,18 @@ usbconn_ftdi_common_open (urj_usbconn_t *conn, urj_log_level_t ll) __func__, ftdi_get_error_string (fc)); urj_error_set (URJ_ERROR_FTD, _("ftdi_usb_open_desc() failed: %s"), ftdi_get_error_string (fc)); - ftdi_deinit (fc); - /* mark ftdi layer as not initialized */ - p->fc = NULL; - - /* TODO: disconnect? */ - return URJ_STATUS_FAIL; + goto open_error; } return URJ_STATUS_OK; + + open_error: + ftdi_deinit (fc); + /* mark ftdi layer as not initialized */ + p->fc = NULL; + + /* TODO: disconnect? */ + return URJ_STATUS_FAIL; } /* ---------------------------------------------------------------------- */