This is an automated email from Gerrit.

"ZhiYuanNJ <871238...@qq.com>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/8091

-- gerrit

commit 2a3242182a5661d6610aaaed59f8f3aecf4f42e0
Author: ZhiYuanNJ <871238...@qq.com>
Date:   Sun Apr 28 10:25:29 2024 +0800

    jtag/drivers: Add support for WCH CH347T/F interfaces
    
    update ch347.c: fix some Writing errors.
    
    Change-Id: I32652909dc73083352c24f0b7e2eecc90471c800
    Signed-off-by: ZhiYuanNJ <871238...@qq.com>

diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c
index 57695f743a..bac63aa474 100644
--- a/src/jtag/drivers/ch347.c
+++ b/src/jtag/drivers/ch347.c
@@ -174,7 +174,7 @@ typedef struct _CH347_SWD_CONTEXT {
        uint8_t *ch347_cmd_buf;
 } CH347_SWD_CONTEXT;
 static CH347_SWD_CONTEXT ch347_swd_context;
-static bool swd_mode = false;
+static bool swd_mode;
 #pragma pack()
 
 #include <jtag/drivers/libusb_helper.h>
@@ -184,14 +184,13 @@ static bool swd_mode = false;
 
 bool ugOpen;
 struct libusb_device_handle *ch347_handle;
-static char* ch347_device_desc;
+static char *ch347_device_desc;
 static uint16_t ch347_vids[] = {DEFAULT_VENDOR_ID, 0};
 static uint16_t ch347_pids[] = {DEFAULT_PRODUCT_ID, 0};
 
 static uint32_t CH347OpenDevice(void)
 {
-       if (jtag_libusb_open(ch347_vids, ch347_pids, ch347_device_desc, 
-                            &ch347_handle, NULL) != ERROR_OK) {
+       if (jtag_libusb_open(ch347_vids, ch347_pids, ch347_device_desc, 
&ch347_handle, NULL) != ERROR_OK) {
                return false;
        } else {
                return true;
@@ -463,7 +462,7 @@ static void CH347_In_Buffer_bytes(uint8_t *bytes, unsigned 
long bytes_length)
                CH347_Flush_Buffer();
 }
 
-static void combinePackets(uint8_t cmd, int cur_idx, unsigned long int len)
+static void combinePackets(uint8_t cmd, int cur_idx, unsigned long len)
 {
        if (cmd != ch347.lastCmd) {
                ch347.buffer[cur_idx] = cmd;
@@ -599,7 +598,7 @@ static int ch347_reset(int trst, int srst)
        LOG_DEBUG_IO("reset trst: %i srst %i", trst, srst);
        unsigned char BitBang[512] = "", BII, i;
        unsigned long TxLen;
-       if (!swd_mode){
+       if (!swd_mode) {
                BII = CH347_CMD_HEADER;
                for (i = 0; i < 7; i++) {
                        BitBang[BII++] = TMS_H | TDI_L | TCK_L;
@@ -828,8 +827,9 @@ static void CH347_WriteRead(struct scan_command *cmd, 
uint8_t *bits,
                                                0,
                                                
&ch347.read_buffer[ch347.read_idx],
                                                offset, num_bits);
-                                       if (num_bits > 7)
+                                       if (num_bits > 7){
                        ch347.read_idx += DIV_ROUND_UP(bit_count, 8);
+                                       }
                                } else {
                                        num_bits = cmd->fields[i].num_bits;
                                        uint8_t *captured = buf_set_buf(
@@ -852,12 +852,12 @@ static void CH347_WriteRead(struct scan_command *cmd, 
uint8_t *bits,
                                                num_bits);
                                        free(captured);
                                }
-                       }else {
+                       } else {
                                LOG_DEBUG_IO("cmd->fields with no data");
                        }
                        if (ch347.pack_size == LARGER_PACK) {
                                offset += num_bits;
-                       }else{
+                       } else {
                                bit_count += cmd->fields[i].num_bits;
                        }
                }
@@ -1076,7 +1076,7 @@ static int ch347_quit(void)
 
 static bool Check_Speed(uint8_t iClockRate)
 {
-       unsigned long int i = 0, j;
+       unsigned long i = 0, j;
        bool retVal;
        uint8_t cmdBuf[32] = "";
        cmdBuf[i++] = CH347_CMD_JTAG_INIT;
@@ -1089,13 +1089,13 @@ static bool Check_Speed(uint8_t iClockRate)
        for (j = 0; j < 4; j++)
                cmdBuf[i++] = ch347.TCK | ch347.TDI | ch347.TMS | ch347.TRST;
 
-       unsigned long int mLength = i;
+       unsigned long mLength = i;
        if (!CH347WriteData(cmdBuf, &mLength) || (mLength != i))
                return false;
 
        mLength = 4;
        memset(cmdBuf, 0, sizeof(cmdBuf));
-       if (!CH347ReadData(cmdBuf, &mLength) || (mLength != 4)){
+       if (!CH347ReadData(cmdBuf, &mLength) || (mLength != 4)) {
                LOG_ERROR("LINE == %d FALSE", __LINE__);
                return false;
        }
@@ -1111,7 +1111,7 @@ static bool CH347Jtag_INIT(uint8_t iClockRate)
                STANDARD_PACK : LARGER_PACK;
        if (ch347.pack_size == STANDARD_PACK) {
                if (iClockRate - 2 < 0)
-                       return Check_Speed( 0);
+                       return Check_Speed(0);
                else
                        return Check_Speed(iClockRate - 2);
        }
@@ -1177,7 +1177,7 @@ static int ch347_khz(int khz, int *jtag_speed)
 
 static int ch347_trst_out(unsigned char status)
 {
-       unsigned long int BI = 0;
+       unsigned long BI = 0;
        unsigned char byte = 0;
        unsigned char cmdPacket[4] = "";
        cmdPacket[BI++] = CH347_CMD_JTAG_BIT_OP;
@@ -1691,8 +1691,7 @@ skip_idle:
 
 skip:
        if (!list_empty(&ch347_swd_context.send_cmd_head)) {
-               list_for_each_safe(pos, tmp, &ch347_swd_context.send_cmd_head)
-               {
+               list_for_each_safe(pos, tmp, &ch347_swd_context.send_cmd_head) {
                        pswd_io = list_entry(pos, CH347_SWD_IO, list_entry);
                        list_del_init(&pswd_io->list_entry);
                        list_add_tail(&pswd_io->list_entry,

-- 

Reply via email to