openocd: fix SPDX tag format for files .c
[fw/openocd] / src / flash / nor / avrf.c
index 51f8d47f710fb54797e5d433382c1ce170fdca72..0e2e263ce5d9086595bd86ed46ae8d2421a48243 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
@@ -134,7 +123,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 +184,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 +255,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 +304,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 +321,7 @@ static int avrf_probe(struct flash_bank *bank)
                }
        }
 
-       if (avr_info != NULL) {
+       if (avr_info) {
                free(bank->sectors);
 
                /* chip found */
@@ -380,7 +369,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 +387,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 +409,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 +427,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__);