From e43979e7020ea9d05a3c0a2af444f292eacb6c53 Mon Sep 17 00:00:00 2001 From: zwelch Date: Tue, 23 Jun 2009 22:35:09 +0000 Subject: - Replace 'if(' with 'if ('. git-svn-id: svn://svn.berlios.de/openocd/trunk@2357 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/arm-jtag-ew.c | 4 +- src/jtag/bitbang.c | 4 +- src/jtag/core.c | 14 +-- src/jtag/dummy.c | 10 +-- src/jtag/interface.c | 2 +- src/jtag/rlink/rlink.c | 222 +++++++++++++++++++++++------------------------ src/jtag/tcl.c | 50 +++++------ src/jtag/usbprog.c | 2 +- src/jtag/vsllink.c | 6 +- src/jtag/zy1000/zy1000.c | 8 +- 10 files changed, 161 insertions(+), 161 deletions(-) (limited to 'src/jtag') diff --git a/src/jtag/arm-jtag-ew.c b/src/jtag/arm-jtag-ew.c index 202bb392..0cc30654 100644 --- a/src/jtag/arm-jtag-ew.c +++ b/src/jtag/arm-jtag-ew.c @@ -220,7 +220,7 @@ static int armjtagew_speed(int speed) usb_out_buffer[0] = CMD_GET_TCK_FREQUENCY; result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4); speed_real = (int)buf_get_u32(usb_in_buffer,0,32); - if(result < 0) + if (result < 0) { LOG_ERROR("ARM-JTAG-EW getting speed failed (%d)", result); return ERROR_JTAG_DEVICE_ERROR; @@ -672,7 +672,7 @@ static int armjtagew_tap_execute(void) int stat; stat = (int)buf_get_u32(usb_in_buffer + byte_length, 0, 32); - if(stat) { + if (stat) { LOG_ERROR("armjtagew_tap_execute, emulator returned error code %d for a CMD_TAP_SHIFT command", stat); return ERROR_JTAG_QUEUE_FAILED; } diff --git a/src/jtag/bitbang.c b/src/jtag/bitbang.c index 0acfc6f4..f39859af 100644 --- a/src/jtag/bitbang.c +++ b/src/jtag/bitbang.c @@ -247,7 +247,7 @@ int bitbang_execute_queue(void) */ retval = ERROR_OK; - if(bitbang_interface->blink) + if (bitbang_interface->blink) bitbang_interface->blink(1); while (cmd) @@ -318,7 +318,7 @@ int bitbang_execute_queue(void) } cmd = cmd->next; } - if(bitbang_interface->blink) + if (bitbang_interface->blink) bitbang_interface->blink(0); return retval; diff --git a/src/jtag/core.c b/src/jtag/core.c index 5bf7295e..ad3fb72f 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -510,11 +510,11 @@ int jtag_add_statemove(tap_state_t goal_state) if (goal_state==cur_state ) ; /* nothing to do */ - else if( goal_state==TAP_RESET ) + else if ( goal_state==TAP_RESET ) { jtag_add_tlr(); } - else if( tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state) ) + else if ( tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state) ) { unsigned tms_bits = tap_get_tms_path(cur_state, goal_state); unsigned tms_count = tap_get_tms_path_len(cur_state, goal_state); @@ -531,7 +531,7 @@ int jtag_add_statemove(tap_state_t goal_state) jtag_add_pathmove(tms_count, moves); } - else if( tap_state_transition(cur_state, true) == goal_state + else if ( tap_state_transition(cur_state, true) == goal_state || tap_state_transition(cur_state, false) == goal_state ) { jtag_add_pathmove(1, &goal_state); @@ -1026,7 +1026,7 @@ int jtag_validate_chain(void) total_ir_length = 0; for(;;){ tap = jtag_tap_next_enabled(tap); - if( tap == NULL ){ + if ( tap == NULL ){ break; } total_ir_length += tap->ir_length; @@ -1050,7 +1050,7 @@ int jtag_validate_chain(void) int val; for(;;){ tap = jtag_tap_next_enabled(tap); - if( tap == NULL ){ + if ( tap == NULL ){ break; } @@ -1130,7 +1130,7 @@ int jtag_interface_init(struct command_context_s *cmd_ctx) LOG_ERROR("JTAG interface has to be specified, see \"interface\" command"); return ERROR_JTAG_INVALID_INTERFACE; } - if(hasKHz) + if (hasKHz) { jtag_interface->khz(jtag_get_speed_khz(), &jtag_speed); hasKHz = false; @@ -1151,7 +1151,7 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx) LOG_DEBUG("Init JTAG chain"); tap = jtag_tap_next_enabled(NULL); - if( tap == NULL ){ + if ( tap == NULL ){ LOG_ERROR("There are no enabled taps?"); return ERROR_JTAG_INIT_FAILED; } diff --git a/src/jtag/dummy.c b/src/jtag/dummy.c index e055f633..6d738ee0 100644 --- a/src/jtag/dummy.c +++ b/src/jtag/dummy.c @@ -85,16 +85,16 @@ static int dummy_read(void) static void dummy_write(int tck, int tms, int tdi) { /* TAP standard: "state transitions occur on rising edge of clock" */ - if( tck != dummy_clock ) + if ( tck != dummy_clock ) { - if( tck ) + if ( tck ) { tap_state_t old_state = dummy_state; dummy_state = tap_state_transition( old_state, tms ); - if( old_state != dummy_state ) + if ( old_state != dummy_state ) { - if( clock_count ) + if ( clock_count ) { LOG_DEBUG("dummy_tap: %d stable clocks", clock_count); clock_count = 0; @@ -103,7 +103,7 @@ static void dummy_write(int tck, int tms, int tdi) LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state) ); #if defined(DEBUG) - if(dummy_state == TAP_DRCAPTURE) + if (dummy_state == TAP_DRCAPTURE) dummy_data = 0x01255043; #endif } diff --git a/src/jtag/interface.c b/src/jtag/interface.c index 14c626ee..9e8c4e41 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -361,7 +361,7 @@ tap_state_t tap_state_by_name(const char *name) for( x = 0 ; x < TAP_NUM_STATES ; x++ ){ /* be nice to the human */ - if( 0 == strcasecmp( name, tap_state_name(x) ) ){ + if ( 0 == strcasecmp( name, tap_state_name(x) ) ){ return x; } } diff --git a/src/jtag/rlink/rlink.c b/src/jtag/rlink/rlink.c index 98170382..5ded30b0 100644 --- a/src/jtag/rlink/rlink.c +++ b/src/jtag/rlink/rlink.c @@ -121,7 +121,7 @@ ep1_generic_commandl( va_list ap; int usb_ret; - if(length > sizeof(usb_buffer)) { + if (length > sizeof(usb_buffer)) { length = sizeof(usb_buffer); } @@ -176,7 +176,7 @@ ep1_memory_read( count = 0; while(remain) { - if(remain > sizeof(usb_buffer)) { + if (remain > sizeof(usb_buffer)) { length = sizeof(usb_buffer); } else { length = remain; @@ -192,7 +192,7 @@ ep1_memory_read( USB_TIMEOUT_MS ); - if(usb_ret < sizeof(usb_buffer)) { + if (usb_ret < sizeof(usb_buffer)) { break; } @@ -202,7 +202,7 @@ ep1_memory_read( USB_TIMEOUT_MS ); - if(usb_ret < length) { + if (usb_ret < length) { break; } @@ -237,7 +237,7 @@ ep1_memory_write( count = 0; while(remain) { - if(remain > (sizeof(usb_buffer) - 4)) { + if (remain > (sizeof(usb_buffer) - 4)) { length = (sizeof(usb_buffer) - 4); } else { length = remain; @@ -263,7 +263,7 @@ ep1_memory_write( USB_TIMEOUT_MS ); - if((size_t)usb_ret < sizeof(usb_buffer)) { + if ((size_t)usb_ret < sizeof(usb_buffer)) { break; } @@ -291,7 +291,7 @@ ep1_memory_writel( va_list ap; size_t remain; - if(length > sizeof(buffer)) { + if (length > sizeof(buffer)) { length = sizeof(buffer); } @@ -346,10 +346,10 @@ dtc_load_from_buffer( pHDev, 1, EP1_CMD_DTC_STOP ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); while(length) { - if(length < sizeof(*header)) { + if (length < sizeof(*header)) { LOG_ERROR("Malformed DTC image\n"); exit(1); } @@ -358,7 +358,7 @@ dtc_load_from_buffer( buffer += sizeof(*header); length -= sizeof(*header); - if(length < (size_t)header->length + 1) { + if (length < (size_t)header->length + 1) { LOG_ERROR("Malformed DTC image\n"); exit(1); } @@ -369,7 +369,7 @@ dtc_load_from_buffer( case DTCLOAD_ENTRY: /* store entry addresses somewhere */ - if(!strncmp("download", (char *)buffer + 1, 8)) { + if (!strncmp("download", (char *)buffer + 1, 8)) { dtc_entry_download = buffer[0]; } break; @@ -381,7 +381,7 @@ dtc_load_from_buffer( DTC_LOAD_BUFFER, header->length + 1, buffer ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); /* Load it into the DTC. */ usb_err = ep1_generic_commandl( @@ -390,7 +390,7 @@ dtc_load_from_buffer( (DTC_LOAD_BUFFER >> 8), DTC_LOAD_BUFFER ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); break; @@ -401,7 +401,7 @@ dtc_load_from_buffer( buffer[0], EP1_CMD_DTC_WAIT ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); break; @@ -415,7 +415,7 @@ dtc_load_from_buffer( ST7_USB_BUF_EP0OUT + lut_start, header->length + 1, buffer ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); break; default: @@ -453,7 +453,7 @@ dtc_start_download(void) { ST7_EP2TXR, 1 ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); /* read back ep2txr */ usb_err = usb_bulk_read( @@ -461,7 +461,7 @@ dtc_start_download(void) { (char *)&ep2txr, 1, USB_TIMEOUT_MS ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); usb_err = ep1_generic_commandl( pHDev, 13, @@ -480,7 +480,7 @@ dtc_start_download(void) { dtc_entry_download, EP1_CMD_DTC_GET_CACHED_STATUS ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); /* wait for completion */ usb_err = usb_bulk_read( @@ -514,7 +514,7 @@ dtc_run_download( (char *)command_buffer, USB_EP2BANK_SIZE, USB_TIMEOUT_MS ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); /* Wait for DTC to finish running command buffer */ @@ -527,7 +527,7 @@ dtc_run_download( DTC_STATUS_POLL_BYTE, 1 ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); usb_err = usb_bulk_read( pHDev, @@ -535,11 +535,11 @@ dtc_run_download( (char *)ep2_buffer, 1, USB_TIMEOUT_MS ); - if(usb_err < 0) return(usb_err); + if (usb_err < 0) return(usb_err); - if(ep2_buffer[0] & 0x01) break; + if (ep2_buffer[0] & 0x01) break; - if(!--i) { + if (!--i) { LOG_ERROR("%s, %d: too many retries waiting for DTC status\n", __FILE__, __LINE__ ); @@ -548,8 +548,8 @@ dtc_run_download( } - if(!reply_buffer) reply_buffer_size = 0; - if(reply_buffer_size) { + if (!reply_buffer) reply_buffer_size = 0; + if (reply_buffer_size) { usb_err = usb_bulk_read( pHDev, USB_EP2IN_ADDR, @@ -557,7 +557,7 @@ dtc_run_download( USB_TIMEOUT_MS ); - if(usb_err < (int)sizeof(ep2_buffer)) { + if (usb_err < (int)sizeof(ep2_buffer)) { LOG_ERROR("%s, %d: Read of endpoint 2 returned %d\n", __FILE__, __LINE__, usb_err ); @@ -643,7 +643,7 @@ dtc_queue_enqueue_reply( dtc_reply_queue_entry_t *rq_entry; rq_entry = malloc(sizeof(dtc_reply_queue_entry_t)); - if(rq_entry != NULL) { + if (rq_entry != NULL) { rq_entry->scan.type = type; rq_entry->scan.buffer = buffer; rq_entry->scan.size = size; @@ -652,7 +652,7 @@ dtc_queue_enqueue_reply( rq_entry->cmd = cmd; rq_entry->next = NULL; - if(dtc_queue.rq_head == NULL) + if (dtc_queue.rq_head == NULL) dtc_queue.rq_head = rq_entry; else dtc_queue.rq_tail->next = rq_entry; @@ -683,17 +683,17 @@ dtc_queue_run(void) { retval = ERROR_OK; - if(dtc_queue.cmd_index < 1) return(retval); + if (dtc_queue.cmd_index < 1) return(retval); dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP; /* run the cmd */ - if(dtc_queue.rq_head == NULL) { + if (dtc_queue.rq_head == NULL) { usb_err = dtc_run_download(pHDev, dtc_queue.cmd_buffer, dtc_queue.cmd_index, NULL, 0 ); - if(usb_err < 0) { + if (usb_err < 0) { LOG_ERROR("dtc_run_download: %s\n", usb_strerror()); exit(1); } @@ -702,7 +702,7 @@ dtc_queue_run(void) { dtc_queue.cmd_buffer, dtc_queue.cmd_index, reply_buffer, dtc_queue.reply_index ); - if(usb_err < 0) { + if (usb_err < 0) { LOG_ERROR("dtc_run_download: %s\n", usb_strerror()); exit(1); } else { @@ -721,7 +721,7 @@ dtc_queue_run(void) { bit_cnt = rq_p->scan.length; - if(bit_cnt >= 8) { + if (bit_cnt >= 8) { /* bytes */ dtc_mask = 1 << (8 - 1); @@ -731,20 +731,20 @@ dtc_queue_run(void) { bit_cnt; bit_cnt-- ) { - if(*dtc_p & dtc_mask) { + if (*dtc_p & dtc_mask) { *tdo_p |= tdo_mask; } else { *tdo_p &=~ tdo_mask; } dtc_mask >>= 1; - if(dtc_mask == 0) { + if (dtc_mask == 0) { dtc_p++; dtc_mask = 1 << (8 - 1); } tdo_mask <<= 1; - if(tdo_mask == 0) { + if (tdo_mask == 0) { tdo_p++; tdo_mask = 1; } @@ -753,7 +753,7 @@ dtc_queue_run(void) { /* extra bits or last bit */ x = *dtc_p++; - if(( + if (( rq_p->scan.type == SCAN_IN ) && ( rq_p->scan.offset != rq_p->scan.size - 1 @@ -769,7 +769,7 @@ dtc_queue_run(void) { bit_cnt; bit_cnt-- ) { - if(x & dtc_mask) { + if (x & dtc_mask) { *tdo_p |= tdo_mask; } else { *tdo_p &=~ tdo_mask; @@ -778,7 +778,7 @@ dtc_queue_run(void) { dtc_mask >>= 1; tdo_mask <<= 1; - if(tdo_mask == 0) { + if (tdo_mask == 0) { tdo_p++; tdo_mask = 1; } @@ -786,9 +786,9 @@ dtc_queue_run(void) { } } - if((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) { + if ((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) { /* feed scan buffer back into openocd and free it */ - if(jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) { + if (jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) { retval = ERROR_JTAG_QUEUE_FAILED; } free(rq_p->scan.buffer); @@ -831,27 +831,27 @@ tap_state_queue_run(void) { int retval; retval = 0; - if(!tap_state_queue.length) return(retval); + if (!tap_state_queue.length) return(retval); bits = 1; byte = 0; for(i = tap_state_queue.length; i--;) { byte <<= 1; - if(tap_state_queue.buffer & 1) { + if (tap_state_queue.buffer & 1) { byte |= 1; } - if((bits >= 8) || !i) { + if ((bits >= 8) || !i) { byte <<= (8 - bits); /* make sure there's room for stop, byte op, and one byte */ - if(dtc_queue.cmd_index >= (sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))) { + if (dtc_queue.cmd_index >= (sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))) { dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP; dtc_queue_run(); } #ifdef USE_HARDWARE_SHIFTER_FOR_TMS - if(bits == 8) { + if (bits == 8) { dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_SHIFT_TMS_BYTES(1); } else { @@ -885,12 +885,12 @@ tap_state_queue_append( ) { int retval; - if(tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) { + if (tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) { retval = tap_state_queue_run(); - if(retval != 0) return(retval); + if (retval != 0) return(retval); } - if(tms) { + if (tms) { tap_state_queue.buffer |= (1 << tap_state_queue.length); } tap_state_queue.length++; @@ -1005,7 +1005,7 @@ void rlink_reset(int trst, int srst) ST7_PADR, 1 ); - if(usb_err < 0) { + if (usb_err < 0) { LOG_ERROR("%s", usb_strerror()); exit(1); } @@ -1015,12 +1015,12 @@ void rlink_reset(int trst, int srst) (char *)&bitmap, 1, USB_TIMEOUT_MS ); - if(usb_err < 1) { + if (usb_err < 1) { LOG_ERROR("%s", usb_strerror()); exit(1); } - if(trst) { + if (trst) { bitmap &= ~ST7_PA_NTRST; } else { bitmap |= ST7_PA_NTRST; @@ -1040,7 +1040,7 @@ void rlink_reset(int trst, int srst) ST7_PBDDR, 1 ); - if(usb_err < 0) { + if (usb_err < 0) { LOG_ERROR("%s", usb_strerror()); exit(1); } @@ -1050,12 +1050,12 @@ void rlink_reset(int trst, int srst) (char *)&bitmap, 1, USB_TIMEOUT_MS ); - if(usb_err < 1) { + if (usb_err < 1) { LOG_ERROR("%s", usb_strerror()); exit(1); } - if(srst) { + if (srst) { bitmap |= ST7_PB_NSRST; } else { bitmap &= ~ST7_PB_NSRST; @@ -1071,7 +1071,7 @@ void rlink_reset(int trst, int srst) bitmap, EP1_CMD_DTC_GET_CACHED_STATUS ); - if(usb_err < 0) { + if (usb_err < 0) { LOG_ERROR("%s", usb_strerror()); exit(1); } @@ -1081,7 +1081,7 @@ void rlink_reset(int trst, int srst) (char *)&bitmap, 1, USB_TIMEOUT_MS ); - if(usb_err < 1) { + if (usb_err < 1) { LOG_ERROR("%s", usb_strerror()); exit(1); } @@ -1108,7 +1108,7 @@ rlink_scan( uint8_t tdi_mask, *tdi_p; uint8_t dtc_mask; - if(scan_size < 1) { + if (scan_size < 1) { LOG_ERROR("scan_size cannot be less than 1 bit\n"); exit(1); } @@ -1156,11 +1156,11 @@ rlink_scan( tdi_p = buffer; tdi_mask = 1; - if(extra_bits && (type == SCAN_OUT)) { + if (extra_bits && (type == SCAN_OUT)) { /* Schedule any extra bits into the DTC command buffer, padding as needed */ /* For SCAN_OUT, this comes before the full bytes so the (leading) padding bits will fall off the end */ /* make sure there's room for stop, byte op, and one byte */ - if( + if ( (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1)) ) { dtc_queue_run(); @@ -1170,14 +1170,14 @@ rlink_scan( dtc_mask = 1 << (extra_bits - 1); while(extra_bits--) { - if(*tdi_p & tdi_mask) { + if (*tdi_p & tdi_mask) { x |= dtc_mask; } dtc_mask >>= 1; tdi_mask <<= 1; - if(tdi_mask == 0) { + if (tdi_mask == 0) { tdi_p++; tdi_mask = 1; } @@ -1191,7 +1191,7 @@ rlink_scan( /* Loop scheduling full bytes into the DTC command buffer */ while(byte_bits) { - if(type == SCAN_IN) { + if (type == SCAN_IN) { /* make sure there's room for stop and byte op */ x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1)); } else { @@ -1199,36 +1199,36 @@ rlink_scan( x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1)); } - if(type != SCAN_OUT) { + if (type != SCAN_OUT) { /* make sure there's room for at least one reply byte */ x |= (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1)); } - if(x) { + if (x) { dtc_queue_run(); } chunk_bits = byte_bits; /* we can only use up to 16 bytes at a time */ - if(chunk_bits > (16 * 8)) chunk_bits = (16 * 8); + if (chunk_bits > (16 * 8)) chunk_bits = (16 * 8); - if(type != SCAN_IN) { + if (type != SCAN_IN) { /* how much is there room for, considering stop and byte op? */ x = (sizeof(dtc_queue.cmd_buffer) - (dtc_queue.cmd_index + 1 + 1)) * 8; - if(chunk_bits > x) chunk_bits = x; + if (chunk_bits > x) chunk_bits = x; } - if(type != SCAN_OUT) { + if (type != SCAN_OUT) { /* how much is there room for in the reply buffer? */ x = (USB_EP2IN_SIZE - dtc_queue.reply_index) * 8; - if(chunk_bits > x) chunk_bits = x; + if (chunk_bits > x) chunk_bits = x; } /* so the loop will end */ byte_bits -= chunk_bits; - if(type != SCAN_OUT) { - if(dtc_queue_enqueue_reply( + if (type != SCAN_OUT) { + if (dtc_queue_enqueue_reply( type, buffer, scan_size, tdi_bit_offset, chunk_bits, cmd @@ -1256,17 +1256,17 @@ rlink_scan( } dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x; - if(type != SCAN_IN) { + if (type != SCAN_IN) { x = 0; dtc_mask = 1 << (8 - 1); while(chunk_bits--) { - if(*tdi_p & tdi_mask) { + if (*tdi_p & tdi_mask) { x |= dtc_mask; } dtc_mask >>= 1; - if(dtc_mask == 0) { + if (dtc_mask == 0) { dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x; dtc_queue.reply_index++; x = 0; @@ -1274,7 +1274,7 @@ rlink_scan( } tdi_mask <<= 1; - if(tdi_mask == 0) { + if (tdi_mask == 0) { tdi_p++; tdi_mask = 1; } @@ -1282,10 +1282,10 @@ rlink_scan( } } - if(extra_bits && (type != SCAN_OUT)) { + if (extra_bits && (type != SCAN_OUT)) { /* Schedule any extra bits into the DTC command buffer */ /* make sure there's room for stop, byte op, and one byte */ - if( + if ( (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1)) || (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1)) @@ -1293,7 +1293,7 @@ rlink_scan( dtc_queue_run(); } - if(dtc_queue_enqueue_reply( + if (dtc_queue_enqueue_reply( type, buffer, scan_size, tdi_bit_offset, extra_bits, cmd @@ -1304,7 +1304,7 @@ rlink_scan( tdi_bit_offset += extra_bits; - if(type == SCAN_IN) { + if (type == SCAN_IN) { dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_SHIFT_TDO_BYTES(1); @@ -1316,14 +1316,14 @@ rlink_scan( dtc_mask = 1 << (8 - 1); while(extra_bits--) { - if(*tdi_p & tdi_mask) { + if (*tdi_p & tdi_mask) { x |= dtc_mask; } dtc_mask >>= 1; tdi_mask <<= 1; - if(tdi_mask == 0) { + if (tdi_mask == 0) { tdi_p++; tdi_mask = 1; } @@ -1338,7 +1338,7 @@ rlink_scan( /* Schedule the last bit into the DTC command buffer */ { /* make sure there's room for stop, and bit pair command */ - if( + if ( (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1)) || (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1)) @@ -1346,12 +1346,12 @@ rlink_scan( dtc_queue_run(); } - if(type == SCAN_OUT) { + if (type == SCAN_OUT) { dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(1, (*tdi_p & tdi_mask), 0); } else { - if(dtc_queue_enqueue_reply( + if (dtc_queue_enqueue_reply( type, buffer, scan_size, tdi_bit_offset, 1, cmd @@ -1455,7 +1455,7 @@ int rlink_execute_queue(void) rlink_end_state(cmd->cmd.scan->end_state); scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); type = jtag_scan_type(cmd->cmd.scan); - if(rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) { + if (rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) { retval = ERROR_FAIL; } break; @@ -1475,7 +1475,7 @@ int rlink_execute_queue(void) /* Flush the DTC queue to make sure any pending reads have been done before exiting this function */ tap_state_queue_run(); tmp_retval = dtc_queue_run(); - if(tmp_retval != ERROR_OK) { + if (tmp_retval != ERROR_OK) { retval = tmp_retval; } @@ -1498,19 +1498,19 @@ int rlink_speed(int speed) { int i; - if(speed == 0) { + if (speed == 0) { /* fastest speed */ speed = rlink_speed_table[rlink_speed_table_size - 1].prescaler; } for(i = rlink_speed_table_size; i--; ) { - if(rlink_speed_table[i].prescaler == speed) { - if(dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, rlink_speed_table[i].dtc_size) != 0) { + if (rlink_speed_table[i].prescaler == speed) { + if (dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, rlink_speed_table[i].dtc_size) != 0) { LOG_ERROR("An error occurred while trying to load DTC code for speed \"%d\".\n", speed); exit(1); } - if(dtc_start_download() < 0) { + if (dtc_start_download() < 0) { LOG_ERROR("%s, %d: starting DTC: %s", __FILE__, __LINE__, usb_strerror() @@ -1535,7 +1535,7 @@ int rlink_speed_div( int i; for(i = rlink_speed_table_size; i--; ) { - if(rlink_speed_table[i].prescaler == speed) { + if (rlink_speed_table[i].prescaler == speed) { *khz = rlink_speed_table[i].khz; return(ERROR_OK); } @@ -1553,13 +1553,13 @@ int rlink_khz( ) { int i; - if(khz == 0) { + if (khz == 0) { LOG_ERROR("RCLK not supported"); return ERROR_FAIL; } for(i = rlink_speed_table_size; i--; ) { - if(rlink_speed_table[i].khz <= khz) { + if (rlink_speed_table[i].khz <= khz) { *speed = rlink_speed_table[i].prescaler; return(ERROR_OK); } @@ -1580,7 +1580,7 @@ handle_dtc_directory_command( char **args, int argc ) { - if(argc != 1) { + if (argc != 1) { LOG_ERROR("expected exactly one argument to rlink_dtc_directory "); return(ERROR_INVALID_ARGUMENTS); } @@ -1636,26 +1636,26 @@ int rlink_init(void) for(dev = bus->devices; dev; dev = dev->next) { - if( (dev->descriptor.idVendor == USB_IDVENDOR) && (dev->descriptor.idProduct == USB_IDPRODUCT) ) + if ( (dev->descriptor.idVendor == USB_IDVENDOR) && (dev->descriptor.idProduct == USB_IDPRODUCT) ) { found = 1; LOG_DEBUG("Found device on bus.\n"); do { - if( dev->descriptor.bNumConfigurations > 1 ) + if ( dev->descriptor.bNumConfigurations > 1 ) { LOG_ERROR("Whoops! NumConfigurations is not 1, don't know what to do...\n"); break; } - if( dev->config->bNumInterfaces > 1 ) + if ( dev->config->bNumInterfaces > 1 ) { LOG_ERROR("Whoops! NumInterfaces is not 1, don't know what to do...\n"); break; } pHDev=usb_open(dev); - if( !pHDev ) + if ( !pHDev ) LOG_ERROR ("Failed to open device.\n"); else { @@ -1668,12 +1668,12 @@ int rlink_init(void) do { i = usb_claim_interface(pHDev,0); - if(i) + if (i) { LOG_ERROR("usb_claim_interface: %s", usb_strerror()); #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP j = usb_detach_kernel_driver_np(pHDev, 0); - if(j) + if (j) LOG_ERROR("detach kernel driver: %s", usb_strerror()); #endif } @@ -1684,9 +1684,9 @@ int rlink_init(void) } } while(--retries); - if(!i) + if (!i) { - if( usb_set_altinterface(pHDev,0) ) + if ( usb_set_altinterface(pHDev,0) ) { LOG_ERROR("Failed to set interface.\n"); break; @@ -1700,13 +1700,13 @@ int rlink_init(void) } } - if( !found ) + if ( !found ) { LOG_ERROR("No device found on bus.\n"); exit(1); } - if( !success ) + if ( !success ) { LOG_ERROR("Initialisation failed."); exit(1); @@ -1720,7 +1720,7 @@ int rlink_init(void) pHDev, 1, EP1_CMD_GET_FWREV ); - if(j < USB_EP1OUT_SIZE) { + if (j < USB_EP1OUT_SIZE) { LOG_ERROR("USB write error: %s", usb_strerror()); return(ERROR_FAIL); } @@ -1729,16 +1729,16 @@ int rlink_init(void) (char *)reply_buffer, sizeof(reply_buffer), 200 ); - if(j != -ETIMEDOUT) break; + if (j != -ETIMEDOUT) break; } - if(j < (int)sizeof(reply_buffer)) { + if (j < (int)sizeof(reply_buffer)) { LOG_ERROR("USB read error: %s", usb_strerror()); return(ERROR_FAIL); } LOG_DEBUG(INTERFACE_NAME" firmware version: %d.%d.%d\n", reply_buffer[0], reply_buffer[1], reply_buffer[2]); - if((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) { + if ((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) { LOG_WARNING("The rlink device is not of the version that the developers have played with. It may or may not work.\n"); } @@ -1769,7 +1769,7 @@ int rlink_init(void) USB_TIMEOUT_MS ); - if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) { + if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) { LOG_WARNING("target detection problem\n"); } @@ -1795,7 +1795,7 @@ int rlink_init(void) ); - if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) { + if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) { LOG_WARNING("target not plugged in\n"); } diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index a6c4ded5..13a4da65 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -340,7 +340,7 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi ) /* * we expect CHIP + TAP + OPTIONS * */ - if( goi->argc < 3 ){ + if ( goi->argc < 3 ){ Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ...."); return JIM_ERR; } @@ -369,7 +369,7 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi ) while( goi->argc ){ e = Jim_GetOpt_Nvp( goi, opts, &n ); - if( e != JIM_OK ){ + if ( e != JIM_OK ){ Jim_GetOpt_NvpUnknown( goi, opts, 0 ); return e; } @@ -386,7 +386,7 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi ) uint32_t *new_expected_ids; e = Jim_GetOpt_Wide( goi, &w ); - if( e != JIM_OK) { + if ( e != JIM_OK) { Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name); return e; } @@ -410,7 +410,7 @@ static int jim_newtap_cmd( Jim_GetOptInfo *goi ) case NTAP_OPT_IRMASK: case NTAP_OPT_IRCAPTURE: e = Jim_GetOpt_Wide( goi, &w ); - if( e != JIM_OK ){ + if ( e != JIM_OK ){ Jim_SetResult_sprintf( goi->interp, "option: %s bad parameter", n->name ); return e; } @@ -535,7 +535,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 ); e = Jim_GetOpt_Nvp( &goi, jtag_cmds, &n ); - if( e != JIM_OK ){ + if ( e != JIM_OK ){ Jim_GetOpt_NvpUnknown( &goi, jtag_cmds, 0 ); return e; } @@ -545,19 +545,19 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv /* return the name of the interface */ /* TCL code might need to know the exact type... */ /* FUTURE: we allow this as a means to "set" the interface. */ - if( goi.argc != 0 ){ + if ( goi.argc != 0 ){ Jim_WrongNumArgs( goi.interp, 1, goi.argv-1, "(no params)"); return JIM_ERR; } Jim_SetResultString( goi.interp, jtag_interface->name, -1 ); return JIM_OK; case JTAG_CMD_INIT_RESET: - if( goi.argc != 0 ){ + if ( goi.argc != 0 ){ Jim_WrongNumArgs( goi.interp, 1, goi.argv-1, "(no params)"); return JIM_ERR; } e = jtag_init_reset(context); - if( e != ERROR_OK ){ + if ( e != ERROR_OK ){ Jim_SetResult_sprintf( goi.interp, "error: %d", e); return JIM_ERR; } @@ -568,7 +568,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv case JTAG_CMD_TAPISENABLED: case JTAG_CMD_TAPENABLE: case JTAG_CMD_TAPDISABLE: - if( goi.argc != 1 ){ + if ( goi.argc != 1 ){ Jim_SetResultString( goi.interp, "Too many parameters",-1 ); return JIM_ERR; } @@ -619,7 +619,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv break; case JTAG_CMD_CGET: - if( goi.argc < 2 ){ + if ( goi.argc < 2 ){ Jim_WrongNumArgs( goi.interp, 0, NULL, "?tap-name? -option ..."); return JIM_ERR; } @@ -629,7 +629,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv Jim_GetOpt_Obj(&goi, &o); t = jtag_tap_by_jim_obj( goi.interp, o ); - if( t == NULL ){ + if ( t == NULL ){ return JIM_ERR; } @@ -639,7 +639,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv break; case JTAG_CMD_CONFIGURE: - if( goi.argc < 3 ){ + if ( goi.argc < 3 ){ Jim_WrongNumArgs( goi.interp, 0, NULL, "?tap-name? -option ?VALUE? ..."); return JIM_ERR; } @@ -649,7 +649,7 @@ static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv Jim_GetOpt_Obj(&goi, &o); t = jtag_tap_by_jim_obj( goi.interp, o ); - if( t == NULL ){ + if ( t == NULL ){ return JIM_ERR; } @@ -806,7 +806,7 @@ static int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *c * argv[ 3] = not actually used by anything but in the docs */ - if( argc < 4 ){ + if ( argc < 4 ){ command_print( cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax"); return ERROR_OK; } @@ -847,7 +847,7 @@ static int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *c Jim_GetString( newargs[9], NULL ) ); e = jim_jtag_command( interp, 10, newargs ); - if( e != JIM_OK ){ + if ( e != JIM_OK ){ command_print( cmd_ctx, "%s", Jim_GetString( Jim_GetResult(interp), NULL ) ); } return e; @@ -1174,20 +1174,20 @@ static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, c */ endstate = TAP_IDLE; - if( argc >= 4 ){ + if ( argc >= 4 ){ /* have at least one pair of numbers. */ /* is last pair the magic text? */ - if( 0 == strcmp( "-endstate", args[ argc - 2 ] ) ){ + if ( 0 == strcmp( "-endstate", args[ argc - 2 ] ) ){ const char *cpA; const char *cpS; cpA = args[ argc-1 ]; for( endstate = 0 ; endstate < TAP_NUM_STATES ; endstate++ ){ cpS = tap_state_name( endstate ); - if( 0 == strcmp( cpA, cpS ) ){ + if ( 0 == strcmp( cpA, cpS ) ){ break; } } - if( endstate >= TAP_NUM_STATES ){ + if ( endstate >= TAP_NUM_STATES ){ return ERROR_COMMAND_SYNTAX_ERROR; } else { if (!scan_is_safe(endstate)) @@ -1281,7 +1281,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args e = Jim_GetLong(interp, args[i], &bits); /* If valid - try next arg */ - if( e == JIM_OK ){ + if ( e == JIM_OK ){ continue; } @@ -1299,13 +1299,13 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args /* get arg as a string. */ cp = Jim_GetString( args[i], NULL ); /* is it the magic? */ - if( 0 == strcmp( "-endstate", cp ) ){ + if ( 0 == strcmp( "-endstate", cp ) ){ /* is the statename valid? */ cp = Jim_GetString( args[i+1], NULL ); /* see if it is a valid state name */ endstate = tap_state_by_name(cp); - if( endstate < 0 ){ + if ( endstate < 0 ){ /* update the error message */ Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp ); } else { @@ -1321,13 +1321,13 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args } /* Still an error? */ - if( e != JIM_OK ){ + if ( e != JIM_OK ){ return e; /* too bad */ } } /* validate args */ tap = jtag_tap_by_jim_obj( interp, args[1] ); - if( tap == NULL ){ + if ( tap == NULL ){ return JIM_ERR; } @@ -1401,7 +1401,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar const char *cp; cp = Jim_GetString( args[i+1], NULL ); states[i] = tap_state_by_name(cp); - if( states[i] < 0 ) + if ( states[i] < 0 ) { /* update the error message */ Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp ); diff --git a/src/jtag/usbprog.c b/src/jtag/usbprog.c index 5d9c71b5..ed6472b2 100644 --- a/src/jtag/usbprog.c +++ b/src/jtag/usbprog.c @@ -591,7 +591,7 @@ static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char * buf { send_bits = size; loops = size/8; - /* if(loops==0) */ + /* if (loops==0) */ loops++; size = 0; } diff --git a/src/jtag/vsllink.c b/src/jtag/vsllink.c index a5d001ad..0b52ab18 100644 --- a/src/jtag/vsllink.c +++ b/src/jtag/vsllink.c @@ -1201,12 +1201,12 @@ static void vsllink_scan_normal(bool ir_scan, enum scan_type type, uint8_t *buff { // already in IRSHIFT or DRSHIFT state // merge tms data in the last tms shift command into next scan command - if(*vsllink_tms_cmd_pos < 1) + if (*vsllink_tms_cmd_pos < 1) { LOG_ERROR("There MUST be some bugs in the driver"); exit(-1); } - else if(*vsllink_tms_cmd_pos < 2) + else if (*vsllink_tms_cmd_pos < 2) { tms_tmp = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; vsllink_usb_out_buffer_idx--; @@ -1603,7 +1603,7 @@ static int vsllink_tap_execute_normal(void) if (vsllink_tms_data_len > 0) { - if((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE)) + if ((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE)) { LOG_WARNING("%s is not in RESET or IDLE or PAUSR state", tap_state_name(tap_get_state())); } diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index f4fee3af..3425a4f0 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -127,7 +127,7 @@ jtag_interface_t zy1000_interface = void zy1000_reset(int trst, int srst) { LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst); - if(!srst) + if (!srst) { ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001); } @@ -139,7 +139,7 @@ void zy1000_reset(int trst, int srst) ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001); } - if(!trst) + if (!trst) { ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002); } @@ -188,7 +188,7 @@ void zy1000_reset(int trst, int srst) int zy1000_speed(int speed) { - if(speed == 0) + if (speed == 0) { /*0 means RCLK*/ speed = 0; @@ -197,7 +197,7 @@ int zy1000_speed(int speed) } else { - if(speed > 8190 || speed < 2) + if (speed > 8190 || speed < 2) { LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz"); return ERROR_INVALID_ARGUMENTS; -- cgit v1.2.3