From a9b48a6f481344c592e7e05ca06564cdadfe0721 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Sat, 19 Nov 2022 07:08:32 +0100 Subject: [PATCH] jtag/drivers/cmsis_dap: use dap parameter instead of cmsis_dap_handle Replace the direct dereference of cmsis_dap_handle by dereference of the dap function parameter wherever possible. Signed-off-by: Tomas Vanek Change-Id: I32601dbe0270267642720a8524706aa76d187c3b Reviewed-on: https://review.openocd.org/c/openocd/+/7361 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/jtag/drivers/cmsis_dap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index c2f01f33d..49181ad90 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -290,14 +290,15 @@ static void cmsis_dap_close(struct cmsis_dap *dap) dap->backend = NULL; } - free(cmsis_dap_handle->packet_buffer); - free(cmsis_dap_handle); - cmsis_dap_handle = NULL; + free(dap->packet_buffer); for (int i = 0; i < MAX_PENDING_REQUESTS; i++) { free(dap->pending_fifo[i].transfers); dap->pending_fifo[i].transfers = NULL; } + + free(cmsis_dap_handle); + cmsis_dap_handle = NULL; } static void cmsis_dap_flush_read(struct cmsis_dap *dap) @@ -328,7 +329,7 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) dap->pending_fifo_get_idx = 0; } - uint8_t current_cmd = cmsis_dap_handle->command[0]; + uint8_t current_cmd = dap->command[0]; int retval = dap->backend->write(dap, txlen, LIBUSB_TIMEOUT_MS); if (retval < 0) return retval; @@ -338,7 +339,7 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) if (retval < 0) return retval; - uint8_t *resp = cmsis_dap_handle->response; + uint8_t *resp = dap->response; if (resp[0] == DAP_ERROR) { LOG_ERROR("CMSIS-DAP command 0x%" PRIx8 " not implemented", current_cmd); return ERROR_NOT_IMPLEMENTED; @@ -743,7 +744,7 @@ static int cmsis_dap_cmd_dap_swo_data( static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap) { - uint8_t *command = cmsis_dap_handle->command; + uint8_t *command = dap->command; struct pending_request_block *block = &dap->pending_fifo[dap->pending_fifo_put_idx]; LOG_DEBUG_IO("Executing %d queued transactions from FIFO index %u",