From: <ge...@op...> - 2025-07-26 17:40:14
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9053 -- gerrit commit b62412effdf02480937acbc5082362a51d171b1c Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 18:00:20 2025 +0200 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 <bor...@gm...> diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 6785a74ef1..97c89024b4 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -269,15 +269,15 @@ int adapter_config_rclk(unsigned int fallback_speed_khz) int adapter_get_speed(int *speed) { switch (adapter_config.clock_mode) { - case CLOCK_MODE_KHZ: - adapter_khz_to_speed(adapter_get_speed_khz(), speed); - break; - case CLOCK_MODE_RCLK: - adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed); - break; - default: - LOG_ERROR("BUG: unknown adapter clock mode"); - return ERROR_FAIL; + case CLOCK_MODE_KHZ: + adapter_khz_to_speed(adapter_get_speed_khz(), speed); + break; + case CLOCK_MODE_RCLK: + adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed); + break; + default: + LOG_ERROR("BUG: unknown adapter clock mode"); + return ERROR_FAIL; } return ERROR_OK; } @@ -613,34 +613,34 @@ next: /* minimal JTAG has neither SRST nor TRST (so that's the default) */ switch (new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST)) { - case RESET_HAS_SRST: - modes[0] = "srst_only"; - break; - case RESET_HAS_TRST: - modes[0] = "trst_only"; - break; - case RESET_TRST_AND_SRST: - modes[0] = "trst_and_srst"; - break; - default: - modes[0] = "none"; - break; + case RESET_HAS_SRST: + modes[0] = "srst_only"; + break; + case RESET_HAS_TRST: + modes[0] = "trst_only"; + break; + case RESET_TRST_AND_SRST: + modes[0] = "trst_and_srst"; + break; + default: + modes[0] = "none"; + break; } /* normally SRST and TRST are decoupled; but bugs happen ... */ switch (new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)) { - case RESET_SRST_PULLS_TRST: - modes[1] = "srst_pulls_trst"; - break; - case RESET_TRST_PULLS_SRST: - modes[1] = "trst_pulls_srst"; - break; - case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST: - modes[1] = "combined"; - break; - default: - modes[1] = "separate"; - break; + case RESET_SRST_PULLS_TRST: + modes[1] = "srst_pulls_trst"; + break; + case RESET_TRST_PULLS_SRST: + modes[1] = "trst_pulls_srst"; + break; + case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST: + modes[1] = "combined"; + break; + default: + modes[1] = "separate"; + break; } /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */ diff --git a/src/jtag/core.c b/src/jtag/core.c index 6dd2144c63..479d2efe52 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -969,58 +969,58 @@ int default_interface_jtag_execute_queue(void) while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { switch (cmd->type) { - case JTAG_SCAN: - LOG_DEBUG_IO("JTAG %s SCAN to %s", - cmd->cmd.scan->ir_scan ? "IR" : "DR", - tap_state_name(cmd->cmd.scan->end_state)); - for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) { - struct scan_field *field = cmd->cmd.scan->fields + i; - if (field->out_value) { - char *str = buf_to_hex_str(field->out_value, field->num_bits); - LOG_DEBUG_IO(" %ub out: %s", field->num_bits, 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); - } + case JTAG_SCAN: + LOG_DEBUG_IO("JTAG %s SCAN to %s", + cmd->cmd.scan->ir_scan ? "IR" : "DR", + tap_state_name(cmd->cmd.scan->end_state)); + for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) { + struct scan_field *field = cmd->cmd.scan->fields + i; + if (field->out_value) { + char *str = buf_to_hex_str(field->out_value, field->num_bits); + LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str); + free(str); } - break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("JTAG TLR RESET to %s", - tap_state_name(cmd->cmd.statemove->end_state)); - 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]); + 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; - 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; + } + break; + case JTAG_TLR_RESET: + LOG_DEBUG_IO("JTAG TLR RESET to %s", + tap_state_name(cmd->cmd.statemove->end_state)); + 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: + 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; } @@ -1551,22 +1551,22 @@ int jtag_init_inner(struct command_context *cmd_ctx) */ retval = jtag_examine_chain(); switch (retval) { - case ERROR_OK: - /* complete success */ - break; - default: - /* For backward compatibility reasons, try coping with - * configuration errors involving only ID mismatches. - * We might be able to talk to the devices. - * - * Also the device might be powered down during startup. - * - * After OpenOCD starts, we can try to power on the device - * and run a reset. - */ - LOG_ERROR("Trying to use configured scan chain anyway..."); - issue_setup = false; - break; + case ERROR_OK: + /* complete success */ + break; + default: + /* For backward compatibility reasons, try coping with + * configuration errors involving only ID mismatches. + * We might be able to talk to the devices. + * + * Also the device might be powered down during startup. + * + * After OpenOCD starts, we can try to power on the device + * and run a reset. + */ + LOG_ERROR("Trying to use configured scan chain anyway..."); + issue_setup = false; + break; } /* Now look at IR values. Problems here will prevent real diff --git a/src/jtag/interface.c b/src/jtag/interface.c index 0473a87535..23b5bcf4f1 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -67,28 +67,28 @@ int tap_move_ndx(enum tap_state astate) int ndx; switch (astate) { - case TAP_RESET: - ndx = 0; - break; - case TAP_IDLE: - ndx = 1; - break; - case TAP_DRSHIFT: - ndx = 2; - break; - case TAP_DRPAUSE: - ndx = 3; - break; - case TAP_IRSHIFT: - ndx = 4; - break; - case TAP_IRPAUSE: - ndx = 5; - break; - default: - LOG_ERROR("FATAL: unstable state \"%s\" in %s()", - tap_state_name(astate), __func__); - exit(1); + case TAP_RESET: + ndx = 0; + break; + case TAP_IDLE: + ndx = 1; + break; + case TAP_DRSHIFT: + ndx = 2; + break; + case TAP_DRPAUSE: + ndx = 3; + break; + case TAP_IRSHIFT: + ndx = 4; + break; + case TAP_IRPAUSE: + ndx = 5; + break; + default: + LOG_ERROR("FATAL: unstable state \"%s\" in %s()", + tap_state_name(astate), __func__); + exit(1); } 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. */ switch (astate) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRSHIFT: - case TAP_DRPAUSE: - case TAP_IRSHIFT: - case TAP_IRPAUSE: - is_stable = true; - break; - default: - is_stable = false; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRSHIFT: + case TAP_DRPAUSE: + case TAP_IRSHIFT: + case TAP_IRPAUSE: + is_stable = true; + break; + default: + is_stable = false; } return is_stable; @@ -230,83 +230,83 @@ enum tap_state tap_state_transition(enum tap_state cur_state, bool tms) if (tms) { switch (cur_state) { - case TAP_RESET: - new_state = cur_state; - break; - case TAP_IDLE: - case TAP_DRUPDATE: - case TAP_IRUPDATE: - new_state = TAP_DRSELECT; - break; - case TAP_DRSELECT: - new_state = TAP_IRSELECT; - break; - case TAP_DRCAPTURE: - case TAP_DRSHIFT: - new_state = TAP_DREXIT1; - break; - case TAP_DREXIT1: - case TAP_DREXIT2: - new_state = TAP_DRUPDATE; - break; - case TAP_DRPAUSE: - new_state = TAP_DREXIT2; - break; - case TAP_IRSELECT: - new_state = TAP_RESET; - break; - case TAP_IRCAPTURE: - case TAP_IRSHIFT: - new_state = TAP_IREXIT1; - break; - case TAP_IREXIT1: - case TAP_IREXIT2: - new_state = TAP_IRUPDATE; - break; - case TAP_IRPAUSE: - new_state = TAP_IREXIT2; - break; - default: - LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); - exit(1); - break; + case TAP_RESET: + new_state = cur_state; + break; + case TAP_IDLE: + case TAP_DRUPDATE: + case TAP_IRUPDATE: + new_state = TAP_DRSELECT; + break; + case TAP_DRSELECT: + new_state = TAP_IRSELECT; + break; + case TAP_DRCAPTURE: + case TAP_DRSHIFT: + new_state = TAP_DREXIT1; + break; + case TAP_DREXIT1: + case TAP_DREXIT2: + new_state = TAP_DRUPDATE; + break; + case TAP_DRPAUSE: + new_state = TAP_DREXIT2; + break; + case TAP_IRSELECT: + new_state = TAP_RESET; + break; + case TAP_IRCAPTURE: + case TAP_IRSHIFT: + new_state = TAP_IREXIT1; + break; + case TAP_IREXIT1: + case TAP_IREXIT2: + new_state = TAP_IRUPDATE; + break; + case TAP_IRPAUSE: + new_state = TAP_IREXIT2; + break; + default: + LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); + exit(1); + break; } } else { switch (cur_state) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRUPDATE: - case TAP_IRUPDATE: - new_state = TAP_IDLE; - break; - case TAP_DRSELECT: - new_state = TAP_DRCAPTURE; - break; - case TAP_DRCAPTURE: - case TAP_DRSHIFT: - case TAP_DREXIT2: - new_state = TAP_DRSHIFT; - break; - case TAP_DREXIT1: - case TAP_DRPAUSE: - new_state = TAP_DRPAUSE; - break; - case TAP_IRSELECT: - new_state = TAP_IRCAPTURE; - break; - case TAP_IRCAPTURE: - case TAP_IRSHIFT: - case TAP_IREXIT2: - new_state = TAP_IRSHIFT; - break; - case TAP_IREXIT1: - case TAP_IRPAUSE: - new_state = TAP_IRPAUSE; - break; - default: - LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); - exit(1); - break; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRUPDATE: + case TAP_IRUPDATE: + new_state = TAP_IDLE; + break; + case TAP_DRSELECT: + new_state = TAP_DRCAPTURE; + break; + case TAP_DRCAPTURE: + case TAP_DRSHIFT: + case TAP_DREXIT2: + new_state = TAP_DRSHIFT; + break; + case TAP_DREXIT1: + case TAP_DRPAUSE: + new_state = TAP_DRPAUSE; + break; + case TAP_IRSELECT: + new_state = TAP_IRCAPTURE; + break; + case TAP_IRCAPTURE: + case TAP_IRSHIFT: + case TAP_IREXIT2: + new_state = TAP_IRSHIFT; + break; + case TAP_IREXIT1: + case TAP_IRPAUSE: + new_state = TAP_IRPAUSE; + break; + default: + LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); + exit(1); + break; } } diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 8b0bc7affb..9cffd6b5d1 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -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) { switch (state) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRPAUSE: - case TAP_IRPAUSE: - return true; - default: - return false; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRPAUSE: + case TAP_IRPAUSE: + return true; + default: + return false; } } @@ -558,18 +558,18 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e) } switch (e) { - case JTAG_TAP_EVENT_ENABLE: - case JTAG_TAP_EVENT_DISABLE: - /* NOTE: we currently assume the handlers - * can't fail. Right here is where we should - * really be verifying the scan chains ... - */ - tap->enabled = (e == JTAG_TAP_EVENT_ENABLE); - LOG_INFO("JTAG tap: %s %s", tap->dotted_name, + case JTAG_TAP_EVENT_ENABLE: + case JTAG_TAP_EVENT_DISABLE: + /* NOTE: we currently assume the handlers + * can't fail. Right here is where we should + * really be verifying the scan chains ... + */ + tap->enabled = (e == JTAG_TAP_EVENT_ENABLE); + LOG_INFO("JTAG tap: %s %s", tap->dotted_name, tap->enabled ? "enabled" : "disabled"); - break; - default: - break; + break; + default: + break; } } } -- |