jtag: align switch and case statements

The coding style requires the 'case' to be at the same indentation
level of its 'switch' statement.

Align the code accordingly.

No changes are reported by
	git log -p -w --ignore-blank-lines --patience

Change-Id: Iaf368b0bdd7c797b0e4cfb91e838696d706fdcce
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9053
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
This commit is contained in:
Antonio Borneo
2025-07-26 18:00:20 +02:00
parent 9bc4873a71
commit 8a504640d2
4 changed files with 223 additions and 223 deletions

View File

@@ -271,15 +271,15 @@ int adapter_config_rclk(unsigned int fallback_speed_khz)
int adapter_get_speed(int *speed) int adapter_get_speed(int *speed)
{ {
switch (adapter_config.clock_mode) { switch (adapter_config.clock_mode) {
case CLOCK_MODE_KHZ: case CLOCK_MODE_KHZ:
adapter_khz_to_speed(adapter_get_speed_khz(), speed); adapter_khz_to_speed(adapter_get_speed_khz(), speed);
break; break;
case CLOCK_MODE_RCLK: case CLOCK_MODE_RCLK:
adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed); adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed);
break; break;
default: default:
LOG_ERROR("BUG: unknown adapter clock mode"); LOG_ERROR("BUG: unknown adapter clock mode");
return ERROR_FAIL; return ERROR_FAIL;
} }
return ERROR_OK; return ERROR_OK;
} }
@@ -615,34 +615,34 @@ next:
/* minimal JTAG has neither SRST nor TRST (so that's the default) */ /* minimal JTAG has neither SRST nor TRST (so that's the default) */
switch (new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST)) { switch (new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST)) {
case RESET_HAS_SRST: case RESET_HAS_SRST:
modes[0] = "srst_only"; modes[0] = "srst_only";
break; break;
case RESET_HAS_TRST: case RESET_HAS_TRST:
modes[0] = "trst_only"; modes[0] = "trst_only";
break; break;
case RESET_TRST_AND_SRST: case RESET_TRST_AND_SRST:
modes[0] = "trst_and_srst"; modes[0] = "trst_and_srst";
break; break;
default: default:
modes[0] = "none"; modes[0] = "none";
break; break;
} }
/* normally SRST and TRST are decoupled; but bugs happen ... */ /* normally SRST and TRST are decoupled; but bugs happen ... */
switch (new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)) { switch (new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)) {
case RESET_SRST_PULLS_TRST: case RESET_SRST_PULLS_TRST:
modes[1] = "srst_pulls_trst"; modes[1] = "srst_pulls_trst";
break; break;
case RESET_TRST_PULLS_SRST: case RESET_TRST_PULLS_SRST:
modes[1] = "trst_pulls_srst"; modes[1] = "trst_pulls_srst";
break; break;
case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST: case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST:
modes[1] = "combined"; modes[1] = "combined";
break; break;
default: default:
modes[1] = "separate"; modes[1] = "separate";
break; break;
} }
/* TRST-less connectors include Altera, Xilinx, and minimal JTAG */ /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */

View File

@@ -969,58 +969,58 @@ int default_interface_jtag_execute_queue(void)
while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { while (debug_level >= LOG_LVL_DEBUG_IO && cmd) {
switch (cmd->type) { switch (cmd->type) {
case JTAG_SCAN: case JTAG_SCAN:
LOG_DEBUG_IO("JTAG %s SCAN to %s", LOG_DEBUG_IO("JTAG %s SCAN to %s",
cmd->cmd.scan->ir_scan ? "IR" : "DR", cmd->cmd.scan->ir_scan ? "IR" : "DR",
tap_state_name(cmd->cmd.scan->end_state)); tap_state_name(cmd->cmd.scan->end_state));
for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) { for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) {
struct scan_field *field = cmd->cmd.scan->fields + i; struct scan_field *field = cmd->cmd.scan->fields + i;
if (field->out_value) { if (field->out_value) {
char *str = buf_to_hex_str(field->out_value, field->num_bits); char *str = buf_to_hex_str(field->out_value, field->num_bits);
LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str); LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str);
free(str); free(str);
}
if (field->in_value) {
char *str = buf_to_hex_str(field->in_value, field->num_bits);
LOG_DEBUG_IO(" %ub in: %s", field->num_bits, str);
free(str);
}
} }
break; if (field->in_value) {
case JTAG_TLR_RESET: char *str = buf_to_hex_str(field->in_value, field->num_bits);
LOG_DEBUG_IO("JTAG TLR RESET to %s", LOG_DEBUG_IO(" %ub in: %s", field->num_bits, str);
tap_state_name(cmd->cmd.statemove->end_state)); free(str);
break;
case JTAG_RUNTEST:
LOG_DEBUG_IO("JTAG RUNTEST %d cycles to %s",
cmd->cmd.runtest->num_cycles,
tap_state_name(cmd->cmd.runtest->end_state));
break;
case JTAG_RESET:
{
const char *reset_str[3] = {
"leave", "deassert", "assert"
};
LOG_DEBUG_IO("JTAG RESET %s TRST, %s SRST",
reset_str[cmd->cmd.reset->trst + 1],
reset_str[cmd->cmd.reset->srst + 1]);
} }
break; }
case JTAG_PATHMOVE: break;
LOG_DEBUG_IO("JTAG PATHMOVE (TODO)"); case JTAG_TLR_RESET:
break; LOG_DEBUG_IO("JTAG TLR RESET to %s",
case JTAG_SLEEP: tap_state_name(cmd->cmd.statemove->end_state));
LOG_DEBUG_IO("JTAG SLEEP (TODO)"); break;
break; case JTAG_RUNTEST:
case JTAG_STABLECLOCKS: LOG_DEBUG_IO("JTAG RUNTEST %d cycles to %s",
LOG_DEBUG_IO("JTAG STABLECLOCKS (TODO)"); cmd->cmd.runtest->num_cycles,
break; tap_state_name(cmd->cmd.runtest->end_state));
case JTAG_TMS: break;
LOG_DEBUG_IO("JTAG TMS (TODO)"); case JTAG_RESET:
break; {
default: const char *reset_str[3] = {
LOG_ERROR("Unknown JTAG command: %d", cmd->type); "leave", "deassert", "assert"
break; };
LOG_DEBUG_IO("JTAG RESET %s TRST, %s SRST",
reset_str[cmd->cmd.reset->trst + 1],
reset_str[cmd->cmd.reset->srst + 1]);
}
break;
case JTAG_PATHMOVE:
LOG_DEBUG_IO("JTAG PATHMOVE (TODO)");
break;
case JTAG_SLEEP:
LOG_DEBUG_IO("JTAG SLEEP (TODO)");
break;
case JTAG_STABLECLOCKS:
LOG_DEBUG_IO("JTAG STABLECLOCKS (TODO)");
break;
case JTAG_TMS:
LOG_DEBUG_IO("JTAG TMS (TODO)");
break;
default:
LOG_ERROR("Unknown JTAG command: %d", cmd->type);
break;
} }
cmd = cmd->next; cmd = cmd->next;
} }
@@ -1551,22 +1551,22 @@ int jtag_init_inner(struct command_context *cmd_ctx)
*/ */
retval = jtag_examine_chain(); retval = jtag_examine_chain();
switch (retval) { switch (retval) {
case ERROR_OK: case ERROR_OK:
/* complete success */ /* complete success */
break; break;
default: default:
/* For backward compatibility reasons, try coping with /* For backward compatibility reasons, try coping with
* configuration errors involving only ID mismatches. * configuration errors involving only ID mismatches.
* We might be able to talk to the devices. * We might be able to talk to the devices.
* *
* Also the device might be powered down during startup. * Also the device might be powered down during startup.
* *
* After OpenOCD starts, we can try to power on the device * After OpenOCD starts, we can try to power on the device
* and run a reset. * and run a reset.
*/ */
LOG_ERROR("Trying to use configured scan chain anyway..."); LOG_ERROR("Trying to use configured scan chain anyway...");
issue_setup = false; issue_setup = false;
break; break;
} }
/* Now look at IR values. Problems here will prevent real /* Now look at IR values. Problems here will prevent real

View File

@@ -67,28 +67,28 @@ int tap_move_ndx(enum tap_state astate)
int ndx; int ndx;
switch (astate) { switch (astate) {
case TAP_RESET: case TAP_RESET:
ndx = 0; ndx = 0;
break; break;
case TAP_IDLE: case TAP_IDLE:
ndx = 1; ndx = 1;
break; break;
case TAP_DRSHIFT: case TAP_DRSHIFT:
ndx = 2; ndx = 2;
break; break;
case TAP_DRPAUSE: case TAP_DRPAUSE:
ndx = 3; ndx = 3;
break; break;
case TAP_IRSHIFT: case TAP_IRSHIFT:
ndx = 4; ndx = 4;
break; break;
case TAP_IRPAUSE: case TAP_IRPAUSE:
ndx = 5; ndx = 5;
break; break;
default: default:
LOG_ERROR("FATAL: unstable state \"%s\" in %s()", LOG_ERROR("FATAL: unstable state \"%s\" in %s()",
tap_state_name(astate), __func__); tap_state_name(astate), __func__);
exit(1); exit(1);
} }
return ndx; return ndx;
@@ -205,16 +205,16 @@ bool tap_is_state_stable(enum tap_state astate)
* (not value dependent like an array), and can also check bounds. * (not value dependent like an array), and can also check bounds.
*/ */
switch (astate) { switch (astate) {
case TAP_RESET: case TAP_RESET:
case TAP_IDLE: case TAP_IDLE:
case TAP_DRSHIFT: case TAP_DRSHIFT:
case TAP_DRPAUSE: case TAP_DRPAUSE:
case TAP_IRSHIFT: case TAP_IRSHIFT:
case TAP_IRPAUSE: case TAP_IRPAUSE:
is_stable = true; is_stable = true;
break; break;
default: default:
is_stable = false; is_stable = false;
} }
return is_stable; return is_stable;
@@ -230,83 +230,83 @@ enum tap_state tap_state_transition(enum tap_state cur_state, bool tms)
if (tms) { if (tms) {
switch (cur_state) { switch (cur_state) {
case TAP_RESET: case TAP_RESET:
new_state = cur_state; new_state = cur_state;
break; break;
case TAP_IDLE: case TAP_IDLE:
case TAP_DRUPDATE: case TAP_DRUPDATE:
case TAP_IRUPDATE: case TAP_IRUPDATE:
new_state = TAP_DRSELECT; new_state = TAP_DRSELECT;
break; break;
case TAP_DRSELECT: case TAP_DRSELECT:
new_state = TAP_IRSELECT; new_state = TAP_IRSELECT;
break; break;
case TAP_DRCAPTURE: case TAP_DRCAPTURE:
case TAP_DRSHIFT: case TAP_DRSHIFT:
new_state = TAP_DREXIT1; new_state = TAP_DREXIT1;
break; break;
case TAP_DREXIT1: case TAP_DREXIT1:
case TAP_DREXIT2: case TAP_DREXIT2:
new_state = TAP_DRUPDATE; new_state = TAP_DRUPDATE;
break; break;
case TAP_DRPAUSE: case TAP_DRPAUSE:
new_state = TAP_DREXIT2; new_state = TAP_DREXIT2;
break; break;
case TAP_IRSELECT: case TAP_IRSELECT:
new_state = TAP_RESET; new_state = TAP_RESET;
break; break;
case TAP_IRCAPTURE: case TAP_IRCAPTURE:
case TAP_IRSHIFT: case TAP_IRSHIFT:
new_state = TAP_IREXIT1; new_state = TAP_IREXIT1;
break; break;
case TAP_IREXIT1: case TAP_IREXIT1:
case TAP_IREXIT2: case TAP_IREXIT2:
new_state = TAP_IRUPDATE; new_state = TAP_IRUPDATE;
break; break;
case TAP_IRPAUSE: case TAP_IRPAUSE:
new_state = TAP_IREXIT2; new_state = TAP_IREXIT2;
break; break;
default: default:
LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state);
exit(1); exit(1);
break; break;
} }
} else { } else {
switch (cur_state) { switch (cur_state) {
case TAP_RESET: case TAP_RESET:
case TAP_IDLE: case TAP_IDLE:
case TAP_DRUPDATE: case TAP_DRUPDATE:
case TAP_IRUPDATE: case TAP_IRUPDATE:
new_state = TAP_IDLE; new_state = TAP_IDLE;
break; break;
case TAP_DRSELECT: case TAP_DRSELECT:
new_state = TAP_DRCAPTURE; new_state = TAP_DRCAPTURE;
break; break;
case TAP_DRCAPTURE: case TAP_DRCAPTURE:
case TAP_DRSHIFT: case TAP_DRSHIFT:
case TAP_DREXIT2: case TAP_DREXIT2:
new_state = TAP_DRSHIFT; new_state = TAP_DRSHIFT;
break; break;
case TAP_DREXIT1: case TAP_DREXIT1:
case TAP_DRPAUSE: case TAP_DRPAUSE:
new_state = TAP_DRPAUSE; new_state = TAP_DRPAUSE;
break; break;
case TAP_IRSELECT: case TAP_IRSELECT:
new_state = TAP_IRCAPTURE; new_state = TAP_IRCAPTURE;
break; break;
case TAP_IRCAPTURE: case TAP_IRCAPTURE:
case TAP_IRSHIFT: case TAP_IRSHIFT:
case TAP_IREXIT2: case TAP_IREXIT2:
new_state = TAP_IRSHIFT; new_state = TAP_IRSHIFT;
break; break;
case TAP_IREXIT1: case TAP_IREXIT1:
case TAP_IRPAUSE: case TAP_IRPAUSE:
new_state = TAP_IRPAUSE; new_state = TAP_IRPAUSE;
break; break;
default: default:
LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state);
exit(1); exit(1);
break; break;
} }
} }

View File

@@ -64,13 +64,13 @@ struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
static bool scan_is_safe(enum tap_state state) static bool scan_is_safe(enum tap_state state)
{ {
switch (state) { switch (state) {
case TAP_RESET: case TAP_RESET:
case TAP_IDLE: case TAP_IDLE:
case TAP_DRPAUSE: case TAP_DRPAUSE:
case TAP_IRPAUSE: case TAP_IRPAUSE:
return true; return true;
default: default:
return false; return false;
} }
} }
@@ -558,18 +558,18 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
} }
switch (e) { switch (e) {
case JTAG_TAP_EVENT_ENABLE: case JTAG_TAP_EVENT_ENABLE:
case JTAG_TAP_EVENT_DISABLE: case JTAG_TAP_EVENT_DISABLE:
/* NOTE: we currently assume the handlers /* NOTE: we currently assume the handlers
* can't fail. Right here is where we should * can't fail. Right here is where we should
* really be verifying the scan chains ... * really be verifying the scan chains ...
*/ */
tap->enabled = (e == JTAG_TAP_EVENT_ENABLE); tap->enabled = (e == JTAG_TAP_EVENT_ENABLE);
LOG_INFO("JTAG tap: %s %s", tap->dotted_name, LOG_INFO("JTAG tap: %s %s", tap->dotted_name,
tap->enabled ? "enabled" : "disabled"); tap->enabled ? "enabled" : "disabled");
break; break;
default: default:
break; break;
} }
} }
} }