jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / flash / nor / avrf.c
index 51f8d47f710fb54797e5d433382c1ce170fdca72..1d317a10c6fda68eff3d47c2385abad49ac63e6c 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2009 by Simon Qian                                      *
  *   SimonQian@SimonQian.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
@@ -75,6 +64,7 @@ static const struct avrf_type avft_chips_info[] = {
        {"atmega324pa", 0x9511, 128, 256, 4, 256},
        {"atmega644p", 0x960a, 256, 256, 8, 256},
        {"atmega1284p", 0x9705, 256, 512, 8, 512},
+       {"atmega32u4", 0x9587, 128, 256, 4, 256},
 };
 
 /* avr program functions */
@@ -134,7 +124,7 @@ static int avr_jtagprg_chiperase(struct avr_common *avr)
                        &poll_value,
                        0x3380,
                        AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN);
-               if (ERROR_OK != mcu_execute_queue())
+               if (mcu_execute_queue() != ERROR_OK)
                        return ERROR_FAIL;
                LOG_DEBUG("poll_value = 0x%04" PRIx32 "", poll_value);
        } while (!(poll_value & 0x0200));
@@ -195,7 +185,7 @@ static int avr_jtagprg_writeflashpage(struct avr_common *avr,
                        &poll_value,
                        0x3700,
                        AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN);
-               if (ERROR_OK != mcu_execute_queue())
+               if (mcu_execute_queue() != ERROR_OK)
                        return ERROR_FAIL;
                LOG_DEBUG("poll_value = 0x%04" PRIx32 "", poll_value);
        } while (!(poll_value & 0x0200));
@@ -266,7 +256,7 @@ static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t o
        LOG_DEBUG("offset is 0x%08" PRIx32 "", offset);
        LOG_DEBUG("count is %" PRIu32 "", count);
 
-       if (ERROR_OK != avr_jtagprg_enterprogmode(avr))
+       if (avr_jtagprg_enterprogmode(avr) != ERROR_OK)
                return ERROR_FAIL;
 
        if (bank->size > 0x20000)
@@ -315,7 +305,7 @@ static int avrf_probe(struct flash_bank *bank)
        avrf_info->probed = false;
 
        avr_jtag_read_jtagid(avr, &device_id);
-       if (ERROR_OK != mcu_execute_queue())
+       if (mcu_execute_queue() != ERROR_OK)
                return ERROR_FAIL;
 
        LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
@@ -332,7 +322,7 @@ static int avrf_probe(struct flash_bank *bank)
                }
        }
 
-       if (avr_info != NULL) {
+       if (avr_info) {
                free(bank->sectors);
 
                /* chip found */
@@ -380,7 +370,7 @@ static int avrf_info(struct flash_bank *bank, struct command_invocation *cmd)
        }
 
        avr_jtag_read_jtagid(avr, &device_id);
-       if (ERROR_OK != mcu_execute_queue())
+       if (mcu_execute_queue() != ERROR_OK)
                return ERROR_FAIL;
 
        LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
@@ -398,7 +388,7 @@ static int avrf_info(struct flash_bank *bank, struct command_invocation *cmd)
                }
        }
 
-       if (avr_info != NULL) {
+       if (avr_info) {
                /* chip found */
                command_print_sameline(cmd, "%s - Rev: 0x%" PRIx32 "", avr_info->name,
                        EXTRACT_VER(device_id));
@@ -420,9 +410,9 @@ static int avrf_mass_erase(struct flash_bank *bank)
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       if ((ERROR_OK != avr_jtagprg_enterprogmode(avr))
-           || (ERROR_OK != avr_jtagprg_chiperase(avr))
-           || (ERROR_OK != avr_jtagprg_leaveprogmode(avr)))
+       if ((avr_jtagprg_enterprogmode(avr) != ERROR_OK)
+           || (avr_jtagprg_chiperase(avr) != ERROR_OK)
+           || (avr_jtagprg_leaveprogmode(avr) != ERROR_OK))
                return ERROR_FAIL;
 
        return ERROR_OK;
@@ -438,13 +428,9 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
        if (retval != ERROR_OK)
                return retval;
 
-       if (avrf_mass_erase(bank) == ERROR_OK) {
-               /* set all sectors as erased */
-               for (unsigned int i = 0; i < bank->num_sectors; i++)
-                       bank->sectors[i].is_erased = 1;
-
+       if (avrf_mass_erase(bank) == ERROR_OK)
                command_print(CMD, "avr mass erase complete");
-       else
+       else
                command_print(CMD, "avr mass erase failed");
 
        LOG_DEBUG("%s", __func__);

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)