From 4cff9dc0c17df26b9c1908e5382095f044913877 Mon Sep 17 00:00:00 2001 From: zwelch Date: Mon, 8 Jun 2009 10:56:07 +0000 Subject: Simplify jtag_execute_queue: - Add static inline jtag_error_clear helper to return and clear jtag_error. - Use new helper to shrink body of function to two lines. git-svn-id: svn://svn.berlios.de/openocd/trunk@2117 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/jtag.c | 5 +---- src/jtag/jtag.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index 2caac530..1038aff6 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -914,11 +914,8 @@ int jtag_get_flush_queue_count(void) int jtag_execute_queue(void) { - int retval; jtag_execute_queue_noclear(); - retval=jtag_error; - jtag_error=ERROR_OK; - return retval; + return jtag_error_clear(); } static int jtag_reset_callback(enum jtag_event event, void *priv) diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 01ef58cd..90e8ae0b 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -561,7 +561,16 @@ static __inline__ void jtag_set_error(int error) jtag_error=error; } - +/** + * Resets jtag_error to ERROR_OK, returning its previous value. + * @returns The previous value of @c jtag_error. + */ +static inline int jtag_error_clear(void) +{ + int temp = jtag_error; + jtag_error = ERROR_OK; + return temp; +} /* can be implemented by hw+sw */ extern int jtag_power_dropout(int* dropout); -- cgit v1.2.3