drivers/bcm2835gpio: Migrate to adapter gpio commands
[openocd.git] / src / jtag / drivers / buspirate.c
index 642ad12f44cedcb77e449e233e7f58bdb8ea669c..1de8e2343fce6d8ddc633e3c323c18b6d71706ce 100644 (file)
@@ -1,20 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
 /***************************************************************************
  *   Copyright (C) 2010 by Michal Demin                                    *
  *   based on usbprog.c and arm-jtag-ew.c                                  *
  *   Several fixes by R. Diez in 2013.                                     *
- *                                                                         *
- *   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
@@ -473,51 +462,51 @@ COMMAND_HANDLER(buspirate_handle_port_command)
 
 }
 
-static const struct command_registration buspirate_command_handlers[] = {
+static const struct command_registration buspirate_subcommand_handlers[] = {
        {
-               .name = "buspirate_adc",
+               .name = "adc",
                .handler = &buspirate_handle_adc_command,
                .mode = COMMAND_EXEC,
                .help = "reads voltages on adc pins",
                .usage = "",
        },
        {
-               .name = "buspirate_vreg",
+               .name = "vreg",
                .usage = "<1|0>",
                .handler = &buspirate_handle_vreg_command,
                .mode = COMMAND_CONFIG,
                .help = "changes the state of voltage regulators",
        },
        {
-               .name = "buspirate_pullup",
+               .name = "pullup",
                .usage = "<1|0>",
                .handler = &buspirate_handle_pullup_command,
                .mode = COMMAND_CONFIG,
                .help = "changes the state of pullup",
        },
        {
-               .name = "buspirate_led",
+               .name = "led",
                .usage = "<1|0>",
                .handler = &buspirate_handle_led_command,
                .mode = COMMAND_EXEC,
                .help = "changes the state of led",
        },
        {
-               .name = "buspirate_speed",
+               .name = "speed",
                .usage = "<normal|fast>",
                .handler = &buspirate_handle_speed_command,
                .mode = COMMAND_CONFIG,
                .help = "speed of the interface",
        },
        {
-               .name = "buspirate_mode",
+               .name = "mode",
                .usage = "<normal|open-drain>",
                .handler = &buspirate_handle_mode_command,
                .mode = COMMAND_CONFIG,
                .help = "pin mode of the interface",
        },
        {
-               .name = "buspirate_port",
+               .name = "port",
                .usage = "/dev/ttyUSB0",
                .handler = &buspirate_handle_port_command,
                .mode = COMMAND_CONFIG,
@@ -526,6 +515,17 @@ static const struct command_registration buspirate_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
+static const struct command_registration buspirate_command_handlers[] = {
+       {
+               .name = "buspirate",
+               .mode = COMMAND_ANY,
+               .help = "perform buspirate management",
+               .chain = buspirate_subcommand_handlers,
+               .usage = "",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
 static const struct swd_driver buspirate_swd = {
        .init = buspirate_swd_init,
        .switch_seq = buspirate_swd_switch_seq,
@@ -800,7 +800,7 @@ static void buspirate_tap_append(int tms, int tdi)
                int bit_index = tap_chain_index % 8;
                uint8_t bit = 1 << bit_index;
 
-               if (0 == bit_index) {
+               if (bit_index == 0) {
                        /* Let's say that the TAP shift operation wants to shift 9 bits,
                           so we will be sending to the Bus Pirate a bit count of 9 but still
                           full 16 bits (2 bytes) of shift data.
@@ -1178,13 +1178,13 @@ static int buspirate_serial_setspeed(int fd, char speed, cc_t timeout)
 
        /* set the serial port parameters */
        fcntl(fd, F_SETFL, 0);
-       if (0 != tcgetattr(fd, &t_opt))
+       if (tcgetattr(fd, &t_opt) != 0)
                return -1;
 
-       if (0 != cfsetispeed(&t_opt, baud))
+       if (cfsetispeed(&t_opt, baud) != 0)
                return -1;
 
-       if (0 != cfsetospeed(&t_opt, baud))
+       if (cfsetospeed(&t_opt, baud) != 0)
                return -1;
 
        t_opt.c_cflag |= (CLOCAL | CREAD);
@@ -1206,7 +1206,7 @@ static int buspirate_serial_setspeed(int fd, char speed, cc_t timeout)
        /* Note that, in the past, TCSANOW was used below instead of TCSADRAIN,
           and CMD_UART_SPEED did not work properly then, at least with
           the Bus Pirate v3.5 (USB). */
-       if (0 != tcsetattr(fd, TCSADRAIN, &t_opt)) {
+       if (tcsetattr(fd, TCSADRAIN, &t_opt) != 0) {
                /* According to the Linux documentation, this is actually not enough
                   to detect errors, you need to call tcgetattr() and check that
                   all changes have been performed successfully. */

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)