diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 90270753..153d75bb 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -51,7 +51,7 @@ Constify the cable drivers. * src/tap/cable/generic_usbconn_list.h, src/tap/cable/generic_usbconn.c, - src/tap/cable/generic_usbconn.h: Unify the list of usb cable drivers. + src/tap/cable/generic_usbconn.h: Unify the list of usb sub cable drivers. * src/tap/cable/ft2232.c, src/tap/cable/ft2232_list.h: Unify the list of ftdi usb cable drivers. @@ -67,6 +67,10 @@ cable drivers to unify duplicate code and to help with FTDI part decls. Avoids defining USB cable drivers when support has been disabled. + * src/tap/usbconn.h, src/tap/usbconn.c, src/tap/usbconn_list.h, + src/tap/usbconn/libftd2xx.c, src/tap/usbconn/libftdi.c, + src/tap/usbconn/libusb.c: Unify the usb cable drivers. + 2010-01-22 Mike Frysinger * src/cmd/cmd_bit.c (cmd_bit_print_params): Fix strncat length handling. diff --git a/urjtag/src/tap/usbconn.c b/urjtag/src/tap/usbconn.c index e76dd58b..1f420809 100644 --- a/urjtag/src/tap/usbconn.c +++ b/urjtag/src/tap/usbconn.c @@ -29,31 +29,11 @@ #include -/* @@@@ RFHH stick these into a .h file */ -#ifdef HAVE_LIBUSB -extern urj_usbconn_driver_t urj_tap_usbconn_libusb_driver; -#endif /* HAVE_LIBUSB */ -#ifdef ENABLE_LOWLEVEL_FTD2XX -extern urj_usbconn_driver_t urj_tap_usbconn_ftd2xx_driver; -extern urj_usbconn_driver_t urj_tap_usbconn_ftd2xx_mpsse_driver; -#endif /* ENABLE_LOWLEVEL_FTD2XX */ -#ifdef ENABLE_LOWLEVEL_FTDI -extern urj_usbconn_driver_t urj_tap_usbconn_ftdi_driver; -extern urj_usbconn_driver_t urj_tap_usbconn_ftdi_mpsse_driver; -#endif /* ENABLE_LOWLEVEL_FTDI */ +#include "usbconn.h" urj_usbconn_driver_t *urj_tap_usbconn_drivers[] = { -#ifdef HAVE_LIBUSB - &urj_tap_usbconn_libusb_driver, -#endif /* HAVE_LIBUSB */ -#ifdef ENABLE_LOWLEVEL_FTD2XX - &urj_tap_usbconn_ftd2xx_driver, - &urj_tap_usbconn_ftd2xx_mpsse_driver, -#endif /* ENABLE_LOWLEVEL_FTD2XX */ -#ifdef ENABLE_LOWLEVEL_FTDI - &urj_tap_usbconn_ftdi_driver, - &urj_tap_usbconn_ftdi_mpsse_driver, -#endif /* ENABLE_LOWLEVEL_FTDI */ +#define _URJ_LIST(item) &urj_tap_usbconn_##item##_driver, +#include "usbconn_list.h" NULL /* last must be NULL */ }; diff --git a/urjtag/src/tap/usbconn.h b/urjtag/src/tap/usbconn.h new file mode 100644 index 00000000..6470c2de --- /dev/null +++ b/urjtag/src/tap/usbconn.h @@ -0,0 +1,31 @@ +/* + * $Id: buses.h 1711 2010-01-23 19:12:01Z vapier $ + * + * Copyright (C) 2003 ETC s.r.o. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Marcel Telka , 2003. + * + */ + +#ifndef URJ_CABLE_USBCONN_H +#define URJ_CABLE_USBCONN_H + +#define _URJ_LIST(item) extern urj_usbconn_driver_t urj_tap_usbconn_##item##_driver; +#include "usbconn_list.h" + +#endif /* URJ_CABLE_USBCONN_H */ diff --git a/urjtag/src/tap/usbconn/libftd2xx.c b/urjtag/src/tap/usbconn/libftd2xx.c index 67089a74..157d3440 100644 --- a/urjtag/src/tap/usbconn/libftd2xx.c +++ b/urjtag/src/tap/usbconn/libftd2xx.c @@ -43,7 +43,7 @@ #include #include #include "libftdx.h" - +#include "../usbconn.h" /* enables debug output */ static const char *module = "usbconn_ftd2xx_"; @@ -67,9 +67,6 @@ typedef struct uint8_t *recv_buf; } ftd2xx_param_t; -urj_usbconn_driver_t urj_tap_usbconn_ftd2xx_driver; -urj_usbconn_driver_t urj_tap_usbconn_ftd2xx_mpsse_driver; - static int usbconn_ftd2xx_common_open (urj_usbconn_t *conn, urj_log_level_t ll); static void usbconn_ftd2xx_free (urj_usbconn_t *conn); diff --git a/urjtag/src/tap/usbconn/libftdi.c b/urjtag/src/tap/usbconn/libftdi.c index 5331bd76..0f0e63d4 100644 --- a/urjtag/src/tap/usbconn/libftdi.c +++ b/urjtag/src/tap/usbconn/libftdi.c @@ -43,6 +43,7 @@ #include #include #include "libftdx.h" +#include "../usbconn.h" typedef struct { @@ -62,9 +63,6 @@ typedef struct uint8_t *recv_buf; } ftdi_param_t; -urj_usbconn_driver_t urj_tap_usbconn_ftdi_driver; -urj_usbconn_driver_t urj_tap_usbconn_ftdi_mpsse_driver; - static int usbconn_ftdi_common_open (urj_usbconn_t *conn, urj_log_level_t ll); static void usbconn_ftdi_free (urj_usbconn_t *conn); diff --git a/urjtag/src/tap/usbconn/libusb.c b/urjtag/src/tap/usbconn/libusb.c index f630783a..a11103fa 100644 --- a/urjtag/src/tap/usbconn/libusb.c +++ b/urjtag/src/tap/usbconn/libusb.c @@ -46,6 +46,7 @@ #include #include #include +#include "../usbconn.h" typedef struct { @@ -53,8 +54,6 @@ typedef struct struct usb_dev_handle *handle; } urj_usbconn_libusb_param_t; -urj_usbconn_driver_t urj_tap_usbconn_libusb_driver; - /* ---------------------------------------------------------------------- */ static int diff --git a/urjtag/src/tap/usbconn_list.h b/urjtag/src/tap/usbconn_list.h new file mode 100644 index 00000000..e80ab0d4 --- /dev/null +++ b/urjtag/src/tap/usbconn_list.h @@ -0,0 +1,37 @@ +/* + * $Id: buses.h 1687 2009-12-29 23:53:09Z arniml $ + * + * Copyright (C) 2003 ETC s.r.o. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Marcel Telka , 2003. + * + */ + +#ifdef HAVE_LIBUSB +_URJ_LIST(libusb) +#endif +#ifdef ENABLE_LOWLEVEL_FTD2XX +_URJ_LIST(ftd2xx) +_URJ_LIST(ftd2xx_mpsse) +#endif +#ifdef ENABLE_LOWLEVEL_FTDI +_URJ_LIST(ftdi) +_URJ_LIST(ftdi_mpsse) +#endif + +#undef _URJ_LIST