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 <vanekt@fbl.cz>
Change-Id: I32601dbe0270267642720a8524706aa76d187c3b
Reviewed-on: https://review.openocd.org/c/openocd/+/7361
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tomas Vanek 2022-11-19 07:08:32 +01:00 committed by Antonio Borneo
parent 128736d23f
commit a9b48a6f48
1 changed files with 7 additions and 6 deletions

View File

@ -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",