openocd: fix SPDX tag format for files .c
[fw/openocd] / src / jtag / aice / aice_usb.c
index 8a8b8308839b49f75501529f8d9093ee2eb55173..b5d0f0b6e48777ad3fe248eb783d1f7d5aa245c6 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2013 by Andes Technology                                *
  *   Hsiangkai Wang <hkwang@andestech.com>                                 *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -583,7 +572,7 @@ static int aice_scan_chain(uint32_t *id_codes, uint8_t *num_of_ids)
                if (cmd_ack_code != AICE_CMD_SCAN_CHAIN) {
 
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_SCAN_CHAIN, cmd_ack_code);
                                return ERROR_FAIL;
                        }
@@ -638,8 +627,8 @@ int aice_read_ctrl(uint32_t address, uint32_t *data)
        LOG_DEBUG("READ_CTRL response, data: 0x%" PRIx32, *data);
 
        if (cmd_ack_code != AICE_CMD_READ_CTRL) {
-               LOG_ERROR("aice command error (command=0x%" PRIx32 ", response=0x%" PRIx8 ")",
-                               (uint32_t)AICE_CMD_READ_CTRL, cmd_ack_code);
+               LOG_ERROR("aice command error (command=0x%x, response=0x%" PRIx8 ")",
+                               AICE_CMD_READ_CTRL, cmd_ack_code);
                return ERROR_FAIL;
        }
 
@@ -676,7 +665,7 @@ int aice_write_ctrl(uint32_t address, uint32_t data)
        LOG_DEBUG("WRITE_CTRL response");
 
        if (cmd_ack_code != AICE_CMD_WRITE_CTRL) {
-               LOG_ERROR("aice command error (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+               LOG_ERROR("aice command error (command=0x%x, response=0x%" PRIx8 ")",
                                AICE_CMD_WRITE_CTRL, cmd_ack_code);
                return ERROR_FAIL;
        }
@@ -718,7 +707,7 @@ static int aice_read_dtr(uint8_t target_id, uint32_t *data)
                } else {
 
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_DTR, cmd_ack_code);
                                return ERROR_FAIL;
                        }
@@ -768,7 +757,7 @@ static int aice_read_dtr_to_buffer(uint8_t target_id, uint32_t buffer_idx)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_READ_DTR_TO_BUFFER, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -820,7 +809,7 @@ static int aice_write_dtr(uint8_t target_id, uint32_t data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_WRITE_DTR, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -871,7 +860,7 @@ static int aice_write_dtr_from_buffer(uint8_t target_id, uint32_t buffer_idx)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_WRITE_DTR_FROM_BUFFER, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -921,7 +910,7 @@ static int aice_read_misc(uint8_t target_id, uint32_t address, uint32_t *data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_MISC, cmd_ack_code);
                                return ERROR_FAIL;
                        }
@@ -976,7 +965,7 @@ static int aice_write_misc(uint8_t target_id, uint32_t address, uint32_t data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_WRITE_MISC, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1026,7 +1015,7 @@ static int aice_read_edmsr(uint8_t target_id, uint32_t address, uint32_t *data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_EDMSR, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1082,7 +1071,7 @@ static int aice_write_edmsr(uint8_t target_id, uint32_t address, uint32_t data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_WRITE_EDMSR, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1165,8 +1154,7 @@ static int aice_write_dim(uint8_t target_id, uint32_t *word, uint8_t num_of_word
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8
-                                               ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_WRITE_DIM, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1220,7 +1208,7 @@ static int aice_do_execute(uint8_t target_id)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_EXECUTE, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1273,7 +1261,7 @@ static int aice_write_mem_b(uint8_t target_id, uint32_t address, uint32_t data)
                                break;
                        } else {
                                if (retry_times > aice_max_retry_times) {
-                                       LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                                       LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                        AICE_CMD_T_WRITE_MEM_B, cmd_ack_code);
 
                                        return ERROR_FAIL;
@@ -1328,7 +1316,7 @@ static int aice_write_mem_h(uint8_t target_id, uint32_t address, uint32_t data)
                                break;
                        } else {
                                if (retry_times > aice_max_retry_times) {
-                                       LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                                       LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                        AICE_CMD_T_WRITE_MEM_H, cmd_ack_code);
 
                                        return ERROR_FAIL;
@@ -1383,7 +1371,7 @@ static int aice_write_mem(uint8_t target_id, uint32_t address, uint32_t data)
                                break;
                        } else {
                                if (retry_times > aice_max_retry_times) {
-                                       LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                                       LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                        AICE_CMD_T_WRITE_MEM, cmd_ack_code);
 
                                        return ERROR_FAIL;
@@ -1434,7 +1422,7 @@ static int aice_fastread_mem(uint8_t target_id, uint8_t *word, uint32_t num_of_w
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_FASTREAD_MEM, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1490,7 +1478,7 @@ static int aice_fastwrite_mem(uint8_t target_id, const uint8_t *word, uint32_t n
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_FASTWRITE_MEM, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1540,7 +1528,7 @@ static int aice_read_mem_b(uint8_t target_id, uint32_t address, uint32_t *data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_MEM_B, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1590,7 +1578,7 @@ static int aice_read_mem_h(uint8_t target_id, uint32_t address, uint32_t *data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_MEM_H, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1641,7 +1629,7 @@ static int aice_read_mem(uint8_t target_id, uint32_t address, uint32_t *data)
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_T_READ_MEM, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1686,7 +1674,7 @@ static int aice_batch_buffer_read(uint8_t buf_index, uint32_t *word, uint32_t nu
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_BATCH_BUFFER_READ, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -1738,7 +1726,7 @@ int aice_batch_buffer_write(uint8_t buf_index, const uint8_t *word, uint32_t num
                        break;
                } else {
                        if (retry_times > aice_max_retry_times) {
-                               LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+                               LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
                                                AICE_CMD_BATCH_BUFFER_WRITE, cmd_ack_code);
 
                                return ERROR_FAIL;
@@ -2086,7 +2074,7 @@ static int aice_usb_open(struct aice_port_param_s *param)
        const uint16_t pids[] = { param->pid, 0 };
        struct libusb_device_handle *devh;
 
-       if (jtag_libusb_open(vids, pids, NULL, &devh, NULL) != ERROR_OK)
+       if (jtag_libusb_open(vids, pids, &devh, NULL) != ERROR_OK)
                return ERROR_FAIL;
 
        /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
@@ -2110,7 +2098,7 @@ static int aice_usb_open(struct aice_port_param_s *param)
        /* reopen jlink after usb_reset
         * on win32 this may take a second or two to re-enumerate */
        int retval;
-       while ((retval = jtag_libusb_open(vids, pids, NULL, &devh, NULL)) != ERROR_OK) {
+       while ((retval = jtag_libusb_open(vids, pids, &devh, NULL)) != ERROR_OK) {
                usleep(1000);
                timeout--;
                if (!timeout)