openocd: fix SPDX tag format for files .c
[openocd.git] / src / jtag / aice / aice_interface.c
index 90871a1386d18028f48cfc1f0f9588ee88ccf4cb..89f82a0aec006d3e4a106568f455f6bbfd5722ea 100644 (file)
@@ -1,25 +1,15 @@
+// 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"
 #endif
 
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <jtag/commands.h>
 #include <transport/transport.h>
@@ -121,7 +111,7 @@ int aice_init_targets(void)
  */
 static int aice_init(void)
 {
-       if (ERROR_OK != aice_port->api->open(&param)) {
+       if (aice_port->api->open(&param) != ERROR_OK) {
                LOG_ERROR("Cannot find AICE Interface! Please check "
                                "connection and permissions.");
                return ERROR_JTAG_INIT_FAILED;
@@ -217,7 +207,7 @@ static int aice_khz(int khz, int *jtag_speed)
        int i;
        for (i = 0 ; i < AICE_KHZ_TO_SPEED_MAP_SIZE ; i++) {
                if (khz == aice_khz_to_speed_map[i]) {
-                       if (8 <= i)
+                       if (i >= 8)
                                *jtag_speed = i | AICE_TCK_CONTROL_TCK3048;
                        else
                                *jtag_speed = i;
@@ -252,8 +242,8 @@ int aice_scan_jtag_chain(void)
                return res;
        }
 
-       for (uint32_t i = 0; i < num_of_idcode; i++)
-               LOG_DEBUG("id_codes[%d] = 0x%x", i, aice_target_id_codes[i]);
+       for (unsigned int i = 0; i < num_of_idcode; i++)
+               LOG_DEBUG("id_codes[%u] = 0x%" PRIx32, i, aice_target_id_codes[i]);
 
        /* Update tap idcode */
        for (target = all_targets; target; target = target->next)
@@ -269,7 +259,7 @@ COMMAND_HANDLER(aice_handle_aice_info_command)
        LOG_DEBUG("aice_handle_aice_info_command");
 
        command_print(CMD, "Description: %s", param.device_desc);
-       command_print(CMD, "Serial number: %s", param.serial);
+       command_print(CMD, "Serial number: %s", adapter_get_required_serial());
        if (strncmp(aice_port->name, "aice_pipe", 9) == 0)
                command_print(CMD, "Adapter: %s", param.adapter_name);
 
@@ -308,18 +298,6 @@ COMMAND_HANDLER(aice_handle_aice_desc_command)
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(aice_handle_aice_serial_command)
-{
-       LOG_DEBUG("aice_handle_aice_serial_command");
-
-       if (CMD_ARGC == 1)
-               param.serial = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("expected exactly one argument to aice serial <serial-number>");
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(aice_handle_aice_vid_pid_command)
 {
        LOG_DEBUG("aice_handle_aice_vid_pid_command");
@@ -422,83 +400,76 @@ static const struct command_registration aice_subcommand_handlers[] = {
                .handler = &aice_handle_aice_info_command,
                .mode = COMMAND_EXEC,
                .help = "show aice info",
-               .usage = "aice info",
+               .usage = "",
        },
        {
                .name = "port",
                .handler = &aice_handle_aice_port_command,
                .mode = COMMAND_CONFIG,
                .help = "set the port of the AICE",
-               .usage = "aice port ['aice_pipe'|'aice_usb']",
+               .usage = "['aice_pipe'|'aice_usb']",
        },
        {
                .name = "desc",
                .handler = &aice_handle_aice_desc_command,
                .mode = COMMAND_CONFIG,
                .help = "set the aice device description",
-               .usage = "aice desc [desciption string]",
-       },
-       {
-               .name = "serial",
-               .handler = &aice_handle_aice_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "set the serial number of the AICE device",
-               .usage = "aice serial [serial string]",
+               .usage = "[description string]",
        },
        {
                .name = "vid_pid",
                .handler = &aice_handle_aice_vid_pid_command,
                .mode = COMMAND_CONFIG,
                .help = "the vendor and product ID of the AICE device",
-               .usage = "aice vid_pid (vid pid)*",
+               .usage = "(vid pid)*",
        },
        {
                .name = "adapter",
                .handler = &aice_handle_aice_adapter_command,
                .mode = COMMAND_CONFIG,
                .help = "set the file name of adapter",
-               .usage = "aice adapter [adapter name]",
+               .usage = "[adapter name]",
        },
        {
                .name = "retry_times",
                .handler = &aice_handle_aice_retry_times_command,
                .mode = COMMAND_CONFIG,
                .help = "set retry times as AICE timeout",
-               .usage = "aice retry_times num_of_retry",
+               .usage = "num_of_retry",
        },
        {
                .name = "count_to_check_dbger",
                .handler = &aice_handle_aice_count_to_check_dbger_command,
                .mode = COMMAND_CONFIG,
                .help = "set retry times as checking $DBGER status",
-               .usage = "aice count_to_check_dbger count_of_checking",
+               .usage = "count_of_checking",
        },
        {
                .name = "custom_srst_script",
                .handler = &aice_handle_aice_custom_srst_script_command,
                .mode = COMMAND_CONFIG,
-               .usage = "custom_srst_script script_file_name",
+               .usage = "script_file_name",
                .help = "set custom srst script",
        },
        {
                .name = "custom_trst_script",
                .handler = &aice_handle_aice_custom_trst_script_command,
                .mode = COMMAND_CONFIG,
-               .usage = "custom_trst_script script_file_name",
+               .usage = "script_file_name",
                .help = "set custom trst script",
        },
        {
                .name = "custom_restart_script",
                .handler = &aice_handle_aice_custom_restart_script_command,
                .mode = COMMAND_CONFIG,
-               .usage = "custom_restart_script script_file_name",
+               .usage = "script_file_name",
                .help = "set custom restart script",
        },
        {
                .name = "reset",
                .handler = &aice_handle_aice_reset_command,
                .mode = COMMAND_EXEC,
-               .usage = "aice reset",
+               .usage = "",
                .help = "reset AICE",
        },
        COMMAND_REGISTRATION_DONE
@@ -509,7 +480,7 @@ static const struct command_registration aice_command_handlers[] = {
                .name = "aice",
                .mode = COMMAND_ANY,
                .help = "perform aice management",
-               .usage = "aice [subcommand]",
+               .usage = "[subcommand]",
                .chain = aice_subcommand_handlers,
        },
        COMMAND_REGISTRATION_DONE

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)