Compare commits

...

2 Commits

Author SHA1 Message Date
Antonio Borneo
e971d677c0 drivers ch347: drop useless initialization
Drop some useless initialization in the driver.
Replace a constant value returned through a variable with the
value itself.

Change-Id: I7b7c0b30c6d36e9763ff78bf826742792546fa7f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9095
Tested-by: jenkins
Reviewed-by: Matthias Jentsch <info@easydevkits.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2025-08-27 14:36:55 +00:00
Antonio Borneo
96c219a408 drivers: ch347: fix scan-build warnings
The newly merged driver ch347 triggers two new scan-build warnings
about dead assignment to variables.

Fix them.

Change-Id: Ided14272c3573be1498584e68ac4653cde029f31
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 7d0e125896 ("jtag/drivers: Add support for CH347-based JTAG adapters")
Reviewed-on: https://review.openocd.org/c/openocd/+/9094
Tested-by: jenkins
Reviewed-by: Matthias Jentsch <info@easydevkits.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2025-08-27 14:36:44 +00:00

View File

@@ -793,11 +793,10 @@ static int ch347_cmd_start_next(uint8_t type)
{
// different command type or non chainable command? (GPIO commands can't be concat)
uint8_t prev_type = ch347.scratchpad_cmd_type;
int retval = ERROR_OK;
if (prev_type != type || ch347_is_single_cmd_type(type)) {
// something written in the scratchpad? => store it as command
if (prev_type != 0 && ch347.scratchpad_idx > 0) {
retval = ch347_cmd_from_scratchpad();
int retval = ch347_cmd_from_scratchpad();
if (retval != ERROR_OK)
return retval;
@@ -813,7 +812,7 @@ static int ch347_cmd_start_next(uint8_t type)
/* before we can send non chainable command ("single" like GPIO command) we should send all
other commands because we can't send it together with other commands */
if (ch347_is_single_cmd_type(type)) {
retval = ch347_cmd_transmit_queue();
int retval = ch347_cmd_transmit_queue();
if (retval != ERROR_OK)
return retval;
}
@@ -822,7 +821,7 @@ static int ch347_cmd_start_next(uint8_t type)
ch347.scratchpad_cmd_type = type;
}
return retval;
return ERROR_OK;
}
/**
@@ -863,7 +862,6 @@ static int ch347_single_read_get_byte(int read_buf_idx, uint8_t *byte)
if (read_buf_idx > CH347_SINGLE_CMD_MAX_READ || read_buf_idx < 0) {
LOG_ERROR("read_buf_idx out of range");
read_buf_idx = 0;
return ERROR_FAIL;
}
@@ -981,17 +979,15 @@ static int ch347_scratchpad_add_clock_tms(bool tms)
*/
static int ch347_scratchpad_add_stableclocks(int count)
{
int retval = ERROR_OK;
if (ch347.scratchpad_cmd_type == 0) {
retval = ch347_cmd_start_next(CH347_CMD_JTAG_BIT_OP);
int retval = ch347_cmd_start_next(CH347_CMD_JTAG_BIT_OP);
if (retval != ERROR_OK)
return retval;
}
bool tms = ch347.tms_pin == TMS_H;
retval = ERROR_OK;
for (int i = 0; i < count; i++) {
retval = ch347_scratchpad_add_clock_tms(tms);
int retval = ch347_scratchpad_add_clock_tms(tms);
if (retval != ERROR_OK)
return retval;
}
@@ -1199,7 +1195,7 @@ static int ch347_scratchpad_add_write_read(struct scan_command *cmd, uint8_t *bi
static int ch347_scratchpad_add_run_test(int cycles, enum tap_state state)
{
LOG_DEBUG_IO("cycles=%d, end_state=%d", cycles, state);
int retval = ERROR_OK;
int retval;
if (tap_get_state() != TAP_IDLE) {
retval = ch347_scratchpad_add_move_state(TAP_IDLE, 0);
if (retval != ERROR_OK)
@@ -1228,7 +1224,7 @@ static int ch347_scratchpad_add_scan(struct scan_command *cmd)
int scan_bits = jtag_build_buffer(cmd, &buf);
// add a move to IRSHIFT or DRSHIFT state
int retval = ERROR_OK;
int retval;
if (cmd->ir_scan)
retval = ch347_scratchpad_add_move_state(TAP_IRSHIFT, 0);
else