summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2010-01-03 12:59:51 -0800
committerDavid Brownell <dbrownell@users.sourceforge.net>2010-01-03 12:59:51 -0800
commitd9508b30e096b5cc44a4fdbf2d6b99ca173a43f1 (patch)
tree7b9954b8dda333a9778b0d042558cb8489bca549
parent4ed5b45097cb2c13f9ef0682848c4682b5fd7240 (diff)
downloadopenocd_libswd-d9508b30e096b5cc44a4fdbf2d6b99ca173a43f1.tar.gz
openocd_libswd-d9508b30e096b5cc44a4fdbf2d6b99ca173a43f1.tar.bz2
openocd_libswd-d9508b30e096b5cc44a4fdbf2d6b99ca173a43f1.tar.xz
openocd_libswd-d9508b30e096b5cc44a4fdbf2d6b99ca173a43f1.zip
JTAG/drivers: amt_jtagaccel fixes + cleanup
Build fixes: it failed abysmally with PPDEV enabled. Swapped a build-time error with a FIXME comment in the affected macros. Cleanup: remove "&" before function pointers, and excess indent, for the interface struct declaration. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
-rw-r--r--src/jtag/drivers/amt_jtagaccel.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c
index 8ba15838..de7cdcb6 100644
--- a/src/jtag/drivers/amt_jtagaccel.c
+++ b/src/jtag/drivers/amt_jtagaccel.c
@@ -55,13 +55,41 @@ static int rtck_enabled = 0;
#if PARPORT_USE_PPDEV == 1
static int device_handle;
-static int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR ;
-#define AMT_AW(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); write(device_handle, &val, 1); } while (0)
-#define AMT_AR(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); read(device_handle, &val, 1); } while (0)
-
-static int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA ;
-#define AMT_DW(val) do { ioctl(device_handle, PPSETMODE, &data_mode); write(device_handle, &val, 1); } while (0)
-#define AMT_DR(val) do { ioctl(device_handle, PPSETMODE, &data_mode); read(device_handle, &val, 1); } while (0)
+static const int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
+
+/* FIXME do something sane when these ioctl/read/write calls fail. */
+
+#define AMT_AW(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
+ __retval = write(device_handle, &val, 1); \
+ } while (0)
+#define AMT_AR(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
+ __retval = read(device_handle, &val, 1); \
+ } while (0)
+
+static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
+
+#define AMT_DW(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
+ __retval = write(device_handle, &val, 1); \
+ } while (0)
+#define AMT_DR(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
+ __retval = read(device_handle, &val, 1); \
+ } while (0)
#else
@@ -559,10 +587,11 @@ static const struct command_registration amtjtagaccel_command_handlers[] = {
};
struct jtag_interface amt_jtagaccel_interface = {
- .name = "amt_jtagaccel",
- .commands = amtjtagaccel_command_handlers,
- .init = &amt_jtagaccel_init,
- .quit = &amt_jtagaccel_quit,
- .speed = &amt_jtagaccel_speed,
- .execute_queue = &amt_jtagaccel_execute_queue,
- };
+ .name = "amt_jtagaccel",
+ .commands = amtjtagaccel_command_handlers,
+
+ .init = amt_jtagaccel_init,
+ .quit = amt_jtagaccel_quit,
+ .speed = amt_jtagaccel_speed,
+ .execute_queue = amt_jtagaccel_execute_queue,
+};