This is an automated email from Gerrit. Tarek BOCHKATI ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/6017
-- gerrit commit 0c88bb24dec9ef1c2ed32bf55fb40c9445e88bb3 Author: Tarek BOCHKATI <[email protected]> Date: Mon Jan 18 21:35:54 2021 +0100 stlink: remove unneeded wrappers these wrappers have been added to ease the introduction of backends. now we can get rid of them to ease the renaming of slink driver functions Change-Id: I6aa1f483dc8243da7a170963af5f490bf4c1e4b2 Signed-off-by: Tarek BOCHKATI <[email protected]> diff --git a/src/jtag/drivers/stlink/stlink.c b/src/jtag/drivers/stlink/stlink.c index 94a8b27..69f242f 100644 --- a/src/jtag/drivers/stlink/stlink.c +++ b/src/jtag/drivers/stlink/stlink.c @@ -210,26 +210,6 @@ struct stlink_usb_handle_s { bool reconnect_pending; }; -/** */ -static inline int stlink_usb_open(void *handle, struct hl_interface_param_s *param) -{ - struct stlink_usb_handle_s *h = handle; - return h->backend->open(handle, param); -} - -/** */ -static inline int stlink_usb_close(void *handle) -{ - struct stlink_usb_handle_s *h = handle; - return h->backend->close(handle); -} -/** */ -static inline int stlink_usb_xfer_noerrcheck(void *handle, const uint8_t *buf, int size) -{ - struct stlink_usb_handle_s *h = handle; - return h->backend->xfer_noerrcheck(handle, buf, size); -} - #define STLINK_SWIM_ERR_OK 0x00 #define STLINK_SWIM_BUSY 0x01 #define STLINK_DEBUG_ERR_OK 0x80 @@ -1027,11 +1007,12 @@ static int stlink_usb_error_check(void *handle) */ static int stlink_usb_xfer_errcheck(void *handle, const uint8_t *buf, int size) { + struct stlink_usb_handle_s *h = handle; int retval; assert(size > 0); - retval = stlink_usb_xfer_noerrcheck(handle, buf, size); + retval = h->backend->xfer_noerrcheck(handle, buf, size); if (retval != ERROR_OK) return retval; @@ -1053,7 +1034,7 @@ static int stlink_cmd_allow_retry(void *handle, const uint8_t *buf, int size) while (1) { if ((h->st_mode != STLINK_MODE_DEBUG_SWIM) || !retries) { - res = stlink_usb_xfer_noerrcheck(handle, buf, size); + res = h->backend->xfer_noerrcheck(handle, buf, size); if (res != ERROR_OK) return res; } @@ -1151,7 +1132,7 @@ static int stlink_usb_version(void *handle) h->cmdbuf[h->cmdidx++] = STLINK_GET_VERSION; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 6); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 6); if (res != ERROR_OK) return res; @@ -1192,7 +1173,7 @@ static int stlink_usb_version(void *handle) h->cmdbuf[h->cmdidx++] = STLINK_APIV3_GET_VERSION_EX; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 12); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 12); if (res != ERROR_OK) return res; @@ -1336,7 +1317,7 @@ static int stlink_usb_check_voltage(void *handle, float *target_voltage) h->cmdbuf[h->cmdidx++] = STLINK_GET_TARGET_VOLTAGE; - int result = stlink_usb_xfer_noerrcheck(handle, h->databuf, 8); + int result = h->backend->xfer_noerrcheck(handle, h->databuf, 8); if (result != ERROR_OK) return result; @@ -1415,7 +1396,7 @@ static int stlink_usb_current_mode(void *handle, uint8_t *mode) h->cmdbuf[h->cmdidx++] = STLINK_GET_CURRENT_MODE; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 2); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 2); if (res != ERROR_OK) return res; @@ -1463,7 +1444,7 @@ static int stlink_usb_mode_enter(void *handle, enum stlink_mode type) h->cmdbuf[h->cmdidx++] = STLINK_SWIM_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_SWIM_ENTER; /* swim enter does not return any response or status */ - return stlink_usb_xfer_noerrcheck(handle, h->databuf, 0); + return h->backend->xfer_noerrcheck(handle, h->databuf, 0); case STLINK_MODE_DFU: case STLINK_MODE_MASS: default: @@ -1503,7 +1484,7 @@ static int stlink_usb_mode_leave(void *handle, enum stlink_mode type) return ERROR_FAIL; } - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 0); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 0); if (res != ERROR_OK) return res; @@ -1681,7 +1662,7 @@ static int stlink_swim_status(void *handle) h->cmdbuf[h->cmdidx++] = STLINK_SWIM_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_SWIM_READSTATUS; /* error is checked by the caller */ - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 4); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 4); if (res != ERROR_OK) return res; return ERROR_OK; @@ -1701,7 +1682,7 @@ static int stlink_swim_cap(void *handle, uint8_t *cap) h->cmdbuf[h->cmdidx++] = STLINK_SWIM_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_SWIM_READ_CAP; h->cmdbuf[h->cmdidx++] = 0x01; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 8); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 8); if (res != ERROR_OK) return res; memcpy(cap, h->databuf, 8); @@ -1858,7 +1839,7 @@ static int stlink_swim_readbytes(void *handle, uint32_t addr, uint32_t len, uint stlink_usb_init_buffer(handle, h->rx_ep, len); h->cmdbuf[h->cmdidx++] = STLINK_SWIM_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_SWIM_READBUF; - res = stlink_usb_xfer_noerrcheck(handle, data, len); + res = h->backend->xfer_noerrcheck(handle, data, len); if (res != ERROR_OK) return res; @@ -1885,7 +1866,7 @@ static int stlink_usb_idcode(void *handle, uint32_t *idcode) if (h->version.jtag_api == STLINK_JTAG_API_V1) { h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_READCOREID; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 4); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 4); offset = 0; } else { h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_READ_IDCODES; @@ -1962,7 +1943,7 @@ static int stlink_usb_trace_read(void *handle, uint8_t *buf, size_t *size) h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_GET_TRACE_NB; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 2); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 2); if (res != ERROR_OK) return res; @@ -2026,7 +2007,7 @@ static enum target_state stlink_usb_state(void *handle) h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND; h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_GETSTATUS; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 2); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 2); if (res != ERROR_OK) return TARGET_UNKNOWN; @@ -2226,7 +2207,7 @@ static int stlink_usb_read_regs(void *handle) if (h->version.jtag_api == STLINK_JTAG_API_V1) { h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV1_READALLREGS; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 84); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 84); /* regs data from offset 0 */ } else { h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_READALLREGS; @@ -2264,7 +2245,7 @@ static int stlink_usb_read_reg(void *handle, unsigned int regsel, uint32_t *val) h->cmdbuf[h->cmdidx++] = regsel; if (h->version.jtag_api == STLINK_JTAG_API_V1) { - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, 4); + res = h->backend->xfer_noerrcheck(handle, h->databuf, 4); if (res != ERROR_OK) return res; *val = le_to_h_u32(h->databuf); @@ -2358,7 +2339,7 @@ static int stlink_usb_read_mem8(void *handle, uint32_t addr, uint16_t len, if (read_len == 1) read_len++; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, read_len); + res = h->backend->xfer_noerrcheck(handle, h->databuf, read_len); if (res != ERROR_OK) return res; @@ -2392,7 +2373,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len, h_u16_to_le(h->cmdbuf+h->cmdidx, len); h->cmdidx += 2; - res = stlink_usb_xfer_noerrcheck(handle, buffer, len); + res = h->backend->xfer_noerrcheck(handle, buffer, len); if (res != ERROR_OK) return res; @@ -2427,7 +2408,7 @@ static int stlink_usb_read_mem16(void *handle, uint32_t addr, uint16_t len, h_u16_to_le(h->cmdbuf+h->cmdidx, len); h->cmdidx += 2; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, len); + res = h->backend->xfer_noerrcheck(handle, h->databuf, len); if (res != ERROR_OK) return res; @@ -2464,7 +2445,7 @@ static int stlink_usb_write_mem16(void *handle, uint32_t addr, uint16_t len, h_u16_to_le(h->cmdbuf+h->cmdidx, len); h->cmdidx += 2; - res = stlink_usb_xfer_noerrcheck(handle, buffer, len); + res = h->backend->xfer_noerrcheck(handle, buffer, len); if (res != ERROR_OK) return res; @@ -2496,7 +2477,7 @@ static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len, h_u16_to_le(h->cmdbuf+h->cmdidx, len); h->cmdidx += 2; - res = stlink_usb_xfer_noerrcheck(handle, h->databuf, len); + res = h->backend->xfer_noerrcheck(handle, h->databuf, len); if (res != ERROR_OK) return res; @@ -2530,7 +2511,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len, h_u16_to_le(h->cmdbuf+h->cmdidx, len); h->cmdidx += 2; - res = stlink_usb_xfer_noerrcheck(handle, buffer, len); + res = h->backend->xfer_noerrcheck(handle, buffer, len); if (res != ERROR_OK) return res; @@ -2992,7 +2973,7 @@ static int stlink_close(void *handle) if (handle != NULL) { struct stlink_usb_handle_s *h = handle; - stlink_usb_close(handle); + h->backend->close(handle); free(h); } @@ -3438,7 +3419,7 @@ static int stlink_open(struct hl_interface_param_s *param, enum stlink_mode mode else h->backend = &stlink_usb_backend; - if (stlink_usb_open(h, param) != ERROR_OK) + if (h->backend->open(h, param) != ERROR_OK) goto error_open; /* check if mode is supported */ @@ -3614,7 +3595,7 @@ static int stlink_usb_close_access_port(void *handle, unsigned char ap_num) if (h->version.flags & STLINK_F_FIX_CLOSE_AP) return stlink_usb_xfer_errcheck(handle, h->databuf, 2); else - return stlink_usb_xfer_noerrcheck(handle, h->databuf, 2); + return h->backend->xfer_noerrcheck(handle, h->databuf, 2); } -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
