jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / flash / nor / lpc288x.c
index 474e721eb81403346e5ed54e41ebdb387b5ec0f9..3006db1cbf02d5727b45b7c1d5acedb80bfe1280 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2008 by                                                            *
  *   Karl RobinSod <karl.robinsod@gmail.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/>. *
  ***************************************************************************/
 
 /***************************************************************************
@@ -232,28 +221,17 @@ static uint32_t lpc288x_system_ready(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int lpc288x_erase_check(struct flash_bank *bank)
-{
-       uint32_t status = lpc288x_system_ready(bank);   /* probed? halted? */
-       if (status != ERROR_OK) {
-               LOG_INFO("Processor not halted/not probed");
-               return status;
-       }
-
-       return ERROR_OK;
-}
-
-static int lpc288x_erase(struct flash_bank *bank, int first, int last)
+static int lpc288x_erase(struct flash_bank *bank, unsigned int first,
+               unsigned int last)
 {
        uint32_t status;
-       int sector;
        struct target *target = bank->target;
 
        status = lpc288x_system_ready(bank);    /* probed? halted? */
        if (status != ERROR_OK)
                return status;
 
-       if ((first < 0) || (last < first) || (last >= bank->num_sectors)) {
+       if ((last < first) || (last >= bank->num_sectors)) {
                LOG_INFO("Bad sector range");
                return ERROR_FLASH_SECTOR_INVALID;
        }
@@ -261,7 +239,7 @@ static int lpc288x_erase(struct flash_bank *bank, int first, int last)
        /* Configure the flash controller timing */
        lpc288x_set_flash_clk(bank);
 
-       for (sector = first; sector <= last; sector++) {
+       for (unsigned int sector = first; sector <= last; sector++) {
                if (lpc288x_wait_status_busy(bank, 1000) != ERROR_OK)
                        return ERROR_FLASH_OPERATION_FAILED;
 
@@ -283,7 +261,6 @@ static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_
        struct target *target = bank->target;
        uint32_t bytes_remaining = count;
        uint32_t first_sector, last_sector, sector, page;
-       int i;
 
        /* probed? halted? */
        status = lpc288x_system_ready(bank);
@@ -294,7 +271,7 @@ static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_
        first_sector = last_sector = 0xffffffff;
 
        /* validate the write range... */
-       for (i = 0; i < bank->num_sectors; i++) {
+       for (unsigned int i = 0; i < bank->num_sectors; i++) {
                if ((offset >= bank->sectors[i].offset) &&
                                (offset < (bank->sectors[i].offset + bank->sectors[i].size)) &&
                                (first_sector == 0xffffffff)) {
@@ -390,9 +367,10 @@ static int lpc288x_probe(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last)
+static int lpc288x_protect(struct flash_bank *bank, int set, unsigned int first,
+               unsigned int last)
 {
-       int lockregion, status;
+       int status;
        uint32_t value;
        struct target *target = bank->target;
 
@@ -401,18 +379,18 @@ static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last
        if (status != ERROR_OK)
                return status;
 
-       if ((first < 0) || (last < first) || (last >= bank->num_sectors))
+       if ((last < first) || (last >= bank->num_sectors))
                return ERROR_FLASH_SECTOR_INVALID;
 
        /* Configure the flash controller timing */
        lpc288x_set_flash_clk(bank);
 
-       for (lockregion = first; lockregion <= last; lockregion++) {
+       for (unsigned int lockregion = first; lockregion <= last; lockregion++) {
                if (set) {
-                       /* write an odd value to base addy to protect... */
+                       /* write an odd value to base address to protect... */
                        value = 0x01;
                } else {
-                       /* write an even value to base addy to unprotect... */
+                       /* write an even value to base address to unprotect... */
                        value = 0x00;
                }
                target_write_u32(target, bank->sectors[lockregion].offset, value);
@@ -423,7 +401,7 @@ static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last
        return ERROR_OK;
 }
 
-struct flash_driver lpc288x_flash = {
+const struct flash_driver lpc288x_flash = {
        .name = "lpc288x",
        .flash_bank_command = lpc288x_flash_bank_command,
        .erase = lpc288x_erase,
@@ -432,7 +410,7 @@ struct flash_driver lpc288x_flash = {
        .read = default_flash_read,
        .probe = lpc288x_probe,
        .auto_probe = lpc288x_probe,
-       .erase_check = lpc288x_erase_check,
+       .erase_check = default_flash_blank_check,
        .protect_check = lpc288x_protect_check,
        .free_driver_priv = default_flash_free_driver_priv,
 };

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)