From fe50eceaff056d366a1f33bc21f59fc830e4ca83 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Sat, 8 Feb 2025 22:00:40 +0100 Subject: [PATCH] drivers/ch347: don't loose swd_read/write_reg errors SWD read_reg() and write_reg() methods are declared with void return. Save the error code to ch347_swd_context.queued_retval (will be returned later by SWD run method) instead of ignoring it. Change-Id: Ib95a1bc3398712ac2f8520c79d281633d75f0335 Signed-off-by: Tomas Vanek Reviewed-on: https://review.openocd.org/c/openocd/+/8745 Reviewed-by: ZhiYuanNJ <871238103@qq.com> Tested-by: jenkins --- src/jtag/drivers/ch347.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index 530ac5096..57d1d0fdc 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -2333,13 +2333,17 @@ static int ch347_swd_switch_seq(enum swd_special_seq seq) static void ch347_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk) { assert(cmd & SWD_CMD_RNW); - ch347_swd_queue_cmd(cmd, value, 0, ap_delay_clk); + int retval = ch347_swd_queue_cmd(cmd, value, 0, ap_delay_clk); + if (retval != ERROR_OK) + ch347_swd_context.queued_retval = retval; } static void ch347_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk) { assert(!(cmd & SWD_CMD_RNW)); - ch347_swd_queue_cmd(cmd, NULL, value, ap_delay_clk); + int retval = ch347_swd_queue_cmd(cmd, NULL, value, ap_delay_clk); + if (retval != ERROR_OK) + ch347_swd_context.queued_retval = retval; } static const struct swd_driver ch347_swd = {