flash: nand: move in include file the declaration of 'nand_devices'
[openocd.git] / src / flash / nand / nuc910.c
index 7b598d23ccabed18d7cd63276dbd2a5db1863c86..d7f69e6ae0df90ac6504ef52a8379d215d59ed92 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2010 by Spencer Oliver                                  *
  *   spen@spen-soft.co.uk                                                  *
- *                                                                         *
- *   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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
 /*
@@ -31,8 +18,7 @@
 #include "arm_io.h"
 #include <target/arm.h>
 
-struct nuc910_nand_controller
-{
+struct nuc910_nand_controller {
        struct arm_nand_data io;
 };
 
@@ -53,7 +39,8 @@ static int nuc910_nand_command(struct nand_device *nand, uint8_t command)
        struct target *target = nand->target;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        target_write_u8(target, NUC910_SMCMD, command);
@@ -65,7 +52,8 @@ static int nuc910_nand_address(struct nand_device *nand, uint8_t address)
        struct target *target = nand->target;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        target_write_u32(target, NUC910_SMADDR, ((address & 0xff) | NUC910_SMADDR_EOA));
@@ -77,7 +65,8 @@ static int nuc910_nand_read(struct nand_device *nand, void *data)
        struct target *target = nand->target;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        target_read_u8(target, NUC910_SMDATA, data);
@@ -89,7 +78,8 @@ static int nuc910_nand_write(struct nand_device *nand, uint16_t data)
        struct target *target = nand->target;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        target_write_u8(target, NUC910_SMDATA, data);
@@ -102,7 +92,8 @@ static int nuc910_nand_read_block_data(struct nand_device *nand,
        struct nuc910_nand_controller *nuc910_nand = nand->controller_priv;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        nuc910_nand->io.chunk_size = nand->page_size;
@@ -125,7 +116,8 @@ static int nuc910_nand_write_block_data(struct nand_device *nand,
        struct nuc910_nand_controller *nuc910_nand = nand->controller_priv;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        nuc910_nand->io.chunk_size = nand->page_size;
@@ -154,9 +146,8 @@ static int nuc910_nand_ready(struct nand_device *nand, int timeout)
 
        do {
                target_read_u32(target, NUC910_SMISR, &status);
-               if (status & NUC910_SMISR_RB_) {
+               if (status & NUC910_SMISR_RB_)
                        return 1;
-               }
                alive_sleep(1);
        } while (timeout-- > 0);
 
@@ -181,15 +172,15 @@ static int nuc910_nand_init(struct nand_device *nand)
 {
        struct nuc910_nand_controller *nuc910_nand = nand->controller_priv;
        struct target *target = nand->target;
-       int bus_width = nand->bus_width ? : 8;
+       int bus_width = nand->bus_width ? nand->bus_width : 8;
        int result;
 
-       if ((result = validate_target_state(nand)) != ERROR_OK)
+       result = validate_target_state(nand);
+       if (result != ERROR_OK)
                return result;
 
        /* nuc910 only supports 8bit */
-       if (bus_width != 8)
-       {
+       if (bus_width != 8) {
                LOG_ERROR("nuc910 only supports 8 bit bus width, not %i", bus_width);
                return ERROR_NAND_OPERATION_NOT_SUPPORTED;
        }
@@ -210,8 +201,7 @@ static int nuc910_nand_init(struct nand_device *nand)
        return ERROR_OK;
 }
 
-struct nand_flash_controller nuc910_nand_controller =
-{
+struct nand_flash_controller nuc910_nand_controller = {
        .name = "nuc910",
        .command = nuc910_nand_command,
        .address = nuc910_nand_address,

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)