X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Frlink%2Frlink.c;h=add945807ac493ac9372eccb98039906fb732202;hp=5ded30b0594c08ee8be74a1312f644d6cdf475b7;hb=f90d8fa45f2d4c9d4b7990f198b232ee55cbb4e1;hpb=e43979e7020ea9d05a3c0a2af444f292eacb6c53 diff --git a/src/jtag/rlink/rlink.c b/src/jtag/rlink/rlink.c index 5ded30b059..add945807a 100644 --- a/src/jtag/rlink/rlink.c +++ b/src/jtag/rlink/rlink.c @@ -128,7 +128,7 @@ ep1_generic_commandl( usb_buffer_p = usb_buffer; va_start(ap, length); - while(length > 0) { + while (length > 0) { *usb_buffer_p++ = va_arg(ap, int); length--; } @@ -175,7 +175,7 @@ ep1_memory_read( remain = length; count = 0; - while(remain) { + while (remain) { if (remain > sizeof(usb_buffer)) { length = sizeof(usb_buffer); } else { @@ -236,7 +236,7 @@ ep1_memory_write( remain = length; count = 0; - while(remain) { + while (remain) { if (remain > (sizeof(usb_buffer) - 4)) { length = (sizeof(usb_buffer) - 4); } else { @@ -299,7 +299,7 @@ ep1_memory_writel( buffer_p = buffer; va_start(ap, length); - while(remain > 0) { + while (remain > 0) { *buffer_p++ = va_arg(ap, int); remain--; } @@ -348,7 +348,7 @@ dtc_load_from_buffer( ); if (usb_err < 0) return(usb_err); - while(length) { + while (length) { if (length < sizeof(*header)) { LOG_ERROR("Malformed DTC image\n"); exit(1); @@ -363,7 +363,7 @@ dtc_load_from_buffer( exit(1); } - switch(header->type) { + switch (header->type) { case DTCLOAD_COMMENT: break; @@ -518,7 +518,7 @@ dtc_run_download( /* Wait for DTC to finish running command buffer */ - for(i = 10;;) { + for (i = 10;;) { usb_err = ep1_generic_commandl( pHDev, 4, @@ -711,7 +711,7 @@ dtc_queue_run(void) { /* The rigamarole with the masks and doing it bit-by-bit is due to the fact that the scan buffer is LSb-first and the DTC code is MSb-first for hardware reasons. It was that or craft a function to do the reversal, and that wouldn't work with bit-stuffing (supplying extra bits to use mostly byte operations), or any other scheme which would throw the byte alignment off. */ - for( + for ( rq_p = dtc_queue.rq_head; rq_p != NULL; rq_p = rq_next @@ -726,7 +726,7 @@ dtc_queue_run(void) { dtc_mask = 1 << (8 - 1); - for( + for ( ; bit_cnt; bit_cnt-- @@ -764,7 +764,7 @@ dtc_queue_run(void) { dtc_mask = 1 << (bit_cnt - 1); } - for( + for ( ; bit_cnt; bit_cnt-- @@ -834,7 +834,7 @@ tap_state_queue_run(void) { if (!tap_state_queue.length) return(retval); bits = 1; byte = 0; - for(i = tap_state_queue.length; i--;) { + for (i = tap_state_queue.length; i--;) { byte <<= 1; if (tap_state_queue.buffer & 1) { @@ -915,7 +915,7 @@ void rlink_end_state(tap_state_t state) static void rlink_state_move(void) { - int i=0, tms=0; + int i = 0, tms = 0; uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); @@ -1131,7 +1131,7 @@ rlink_scan( #if 0 - printf("scan_size = %d, type=0x%x\n", scan_size, type); + printf("scan_size = %d, type = 0x%x\n", scan_size, type); { int i; @@ -1140,7 +1140,7 @@ rlink_scan( buffer[scan_size / 8] &= ((1 << ((scan_size - 1) % 8) + 1) - 1); printf("before scan:"); - for(i = 0; i < (scan_size + 7) / 8; i++) { + for (i = 0; i < (scan_size + 7) / 8; i++) { printf(" %02x", buffer[i]); } printf("\n"); @@ -1169,7 +1169,7 @@ rlink_scan( x = 0; dtc_mask = 1 << (extra_bits - 1); - while(extra_bits--) { + while (extra_bits--) { if (*tdi_p & tdi_mask) { x |= dtc_mask; } @@ -1190,7 +1190,7 @@ rlink_scan( } /* Loop scheduling full bytes into the DTC command buffer */ - while(byte_bits) { + while (byte_bits) { 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)); @@ -1243,7 +1243,7 @@ rlink_scan( /* chunk_bits is a multiple of 8, so there are no rounding issues. */ chunk_bytes = chunk_bits / 8; - switch(type) { + switch (type) { case SCAN_IN: x = DTC_CMD_SHIFT_TDO_BYTES(chunk_bytes); break; @@ -1260,7 +1260,7 @@ rlink_scan( x = 0; dtc_mask = 1 << (8 - 1); - while(chunk_bits--) { + while (chunk_bits--) { if (*tdi_p & tdi_mask) { x |= dtc_mask; } @@ -1315,7 +1315,7 @@ rlink_scan( x = 0; dtc_mask = 1 << (8 - 1); - while(extra_bits--) { + while (extra_bits--) { if (*tdi_p & tdi_mask) { x |= dtc_mask; } @@ -1503,7 +1503,7 @@ int rlink_speed(int speed) speed = rlink_speed_table[rlink_speed_table_size - 1].prescaler; } - for(i = rlink_speed_table_size; i--; ) { + 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) { LOG_ERROR("An error occurred while trying to load DTC code for speed \"%d\".\n", speed); @@ -1534,7 +1534,7 @@ int rlink_speed_div( ) { int i; - for(i = rlink_speed_table_size; i--; ) { + for (i = rlink_speed_table_size; i--; ) { if (rlink_speed_table[i].prescaler == speed) { *khz = rlink_speed_table[i].khz; return(ERROR_OK); @@ -1558,7 +1558,7 @@ int rlink_khz( return ERROR_FAIL; } - for(i = rlink_speed_table_size; i--; ) { + for (i = rlink_speed_table_size; i--; ) { if (rlink_speed_table[i].khz <= khz) { *speed = rlink_speed_table[i].prescaler; return(ERROR_OK); @@ -1620,8 +1620,8 @@ int rlink_init(void) struct usb_bus *busses; struct usb_bus *bus; int i, j, retries; - int found=0; - int success=0; + int found = 0; + int success = 0; uint8_t reply_buffer[USB_EP1IN_SIZE]; usb_init(); @@ -1630,32 +1630,32 @@ int rlink_init(void) busses = usb_get_busses(); - for(bus = busses; bus; bus = bus->next) + for (bus = busses; bus; bus = bus->next) { struct usb_device *dev; - for(dev = bus->devices; dev; dev = dev->next) + 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 ) + pHDev = usb_open(dev); + if (!pHDev ) LOG_ERROR ("Failed to open device.\n"); else { @@ -1682,31 +1682,31 @@ int rlink_init(void) LOG_DEBUG("interface claimed!\n"); break; } - } while(--retries); + } while (--retries); if (!i) { - if ( usb_set_altinterface(pHDev,0) ) + if (usb_set_altinterface(pHDev,0) ) { LOG_ERROR("Failed to set interface.\n"); break; } else - success=1; + success = 1; } } - } while(0); + } while (0); } } } - if ( !found ) + if (!found ) { LOG_ERROR("No device found on bus.\n"); exit(1); } - if ( !success ) + if (!success ) { LOG_ERROR("Initialisation failed."); exit(1); @@ -1715,7 +1715,7 @@ int rlink_init(void) /* The device starts out in an unknown state on open. As such, result reads time out, and it's not even known whether the command was accepted. So, for this first command, we issue it repeatedly until its response doesn't time out. Also, if sending a command is going to time out, we'll find that out here. */ /* It must be possible to open the device in such a way that this special magic isn't needed, but, so far, it escapes us. */ - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { j = ep1_generic_commandl( pHDev, 1, EP1_CMD_GET_FWREV