This is an automated email from Gerrit.

Christopher Head ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/5781

-- gerrit

commit 3c788cda463d9e2a3326aea5cd53d2365195a932
Author: Christopher Head <[email protected]>
Date:   Fri Jul 17 14:32:47 2020 -0700

    src/flash/nor: use bool for protect set
    
    Change-Id: If7be8f9c8429b031070aa08a2093d5aa5c9bc736
    Signed-off-by: Christopher Head <[email protected]>

diff --git a/src/flash/nor/ambiqmicro.c b/src/flash/nor/ambiqmicro.c
index 622943d..255613d 100644
--- a/src/flash/nor/ambiqmicro.c
+++ b/src/flash/nor/ambiqmicro.c
@@ -528,7 +528,7 @@ static int ambiqmicro_erase(struct flash_bank *bank, 
unsigned int first,
        return retval;
 }
 
-static int ambiqmicro_protect(struct flash_bank *bank, int set,
+static int ambiqmicro_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        /* struct ambiqmicro_flash_bank *ambiqmicro_info = bank->driver_priv;
diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index c8c4afe..3fbc750 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3282,7 +3282,7 @@ static int sam3_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int sam3_protect(struct flash_bank *bank, int set, unsigned int first,
+static int sam3_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct sam3_bank_private *pPrivate;
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index f282749..7aaec4b 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -2745,7 +2745,7 @@ static int sam4_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int sam4_protect(struct flash_bank *bank, int set, unsigned int first,
+static int sam4_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct sam4_bank_private *pPrivate;
diff --git a/src/flash/nor/at91sam4l.c b/src/flash/nor/at91sam4l.c
index 4ee4ff8..f5c7d62 100644
--- a/src/flash/nor/at91sam4l.c
+++ b/src/flash/nor/at91sam4l.c
@@ -381,7 +381,7 @@ static int sam4l_protect_check(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int sam4l_protect(struct flash_bank *bank, int set, unsigned int first,
+static int sam4l_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct sam4l_info *chip = (struct sam4l_info *)bank->driver_priv;
diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c
index 7dfdf0d..c07560a 100644
--- a/src/flash/nor/at91sam7.c
+++ b/src/flash/nor/at91sam7.c
@@ -851,7 +851,7 @@ static int at91sam7_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int at91sam7_protect(struct flash_bank *bank, int set,
+static int at91sam7_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        uint32_t cmd;
diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c
index 0bd5f59..1bcea4f 100644
--- a/src/flash/nor/at91samd.c
+++ b/src/flash/nor/at91samd.c
@@ -725,7 +725,7 @@ static int samd_modify_user_row(struct target *target, 
uint64_t value,
        return samd_modify_user_row_masked(target, value << startb, mask);
 }
 
-static int samd_protect(struct flash_bank *bank, int set,
+static int samd_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        int res = ERROR_OK;
diff --git a/src/flash/nor/ath79.c b/src/flash/nor/ath79.c
index c30ddf3..1cf4e98 100644
--- a/src/flash/nor/ath79.c
+++ b/src/flash/nor/ath79.c
@@ -542,7 +542,7 @@ static int ath79_erase(struct flash_bank *bank, unsigned 
int first,
        return retval;
 }
 
-static int ath79_protect(struct flash_bank *bank, int set, unsigned int first,
+static int ath79_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c
index ab79e8c..64ae525 100644
--- a/src/flash/nor/atsame5.c
+++ b/src/flash/nor/atsame5.c
@@ -569,7 +569,7 @@ static int same5_modify_user_row(struct target *target, 
uint32_t value,
                        buf_val, buf_mask, 0, 8);
 }
 
-static int same5_protect(struct flash_bank *bank, int set, unsigned int first,
+static int same5_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        int res = ERROR_OK;
diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c
index 1ad37c1..9e17979 100644
--- a/src/flash/nor/atsamv.c
+++ b/src/flash/nor/atsamv.c
@@ -444,7 +444,7 @@ static int samv_erase(struct flash_bank *bank, unsigned int 
first,
        return ERROR_OK;
 }
 
-static int samv_protect(struct flash_bank *bank, int set, unsigned int first,
+static int samv_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        if (bank->target->state != TARGET_HALTED) {
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index 9d2a53a..5305430 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -1002,7 +1002,7 @@ int cfi_erase(struct flash_bank *bank, unsigned int first,
        return ERROR_OK;
 }
 
-static int cfi_intel_protect(struct flash_bank *bank, int set,
+static int cfi_intel_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        int retval;
@@ -1057,7 +1057,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int 
set,
                        if ((block_status & 0x1) != set) {
                                LOG_ERROR(
                                        "couldn't change block lock status (set 
= %i, block_status = 0x%2.2x)",
-                                       set, block_status);
+                                       set ? 1 : 0, block_status);
                                retval = cfi_send_command(bank, 0x70, 
cfi_flash_address(bank, 0, 0x55));
                                if (retval != ERROR_OK)
                                        return retval;
@@ -1114,7 +1114,7 @@ static int cfi_intel_protect(struct flash_bank *bank, int 
set,
        return cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
 }
 
-int cfi_protect(struct flash_bank *bank, int set, unsigned int first,
+int cfi_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
diff --git a/src/flash/nor/cfi.h b/src/flash/nor/cfi.h
index eceb9a4..daf3f80 100644
--- a/src/flash/nor/cfi.h
+++ b/src/flash/nor/cfi.h
@@ -155,7 +155,7 @@ struct cfi_fixup {
 };
 
 int cfi_erase(struct flash_bank *bank, unsigned int first, unsigned int last);
-int cfi_protect(struct flash_bank *bank, int set, unsigned int first,
+int cfi_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last);
 int cfi_probe(struct flash_bank *bank);
 int cfi_auto_probe(struct flash_bank *bank);
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index b1a3662..9c57353 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -49,7 +49,7 @@ int flash_driver_erase(struct flash_bank *bank, unsigned int 
first,
        return retval;
 }
 
-int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
+int flash_driver_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        int retval;
@@ -67,9 +67,6 @@ int flash_driver_protect(struct flash_bank *bank, int set, 
unsigned int first,
                return ERROR_FAIL;
        }
 
-       /* force "set" to 0/1 */
-       set = !!set;
-
        if (bank->driver->protect == NULL) {
                LOG_ERROR("Flash protection is not supported.");
                return ERROR_FLASH_OPER_UNSUPPORTED;
@@ -590,7 +587,7 @@ int flash_erase_address_range(struct target *target,
 static int flash_driver_unprotect(struct flash_bank *bank, unsigned int first,
                unsigned int last)
 {
-       return flash_driver_protect(bank, 0, first, last);
+       return flash_driver_protect(bank, false, first, last);
 }
 
 int flash_unlock_address_range(struct target *target, target_addr_t addr,
diff --git a/src/flash/nor/driver.h b/src/flash/nor/driver.h
index ea8657b..d6f24c9 100644
--- a/src/flash/nor/driver.h
+++ b/src/flash/nor/driver.h
@@ -119,12 +119,12 @@ struct flash_driver {
         * be larger than the first..last range.
         *
         * @param bank The bank to protect or unprotect.
-        * @param set If non-zero, enable protection; if 0, disable it.
+        * @param set If true, enable protection; if false, disable it.
         * @param first The first sector to (un)protect, typicaly 0.
         * @param last The last sector to (un)project, typically N-1.
         * @returns ERROR_OK if successful; otherwise, an error code.
         */
-       int (*protect)(struct flash_bank *bank, int set, unsigned int first,
+       int (*protect)(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last);
 
        /**
diff --git a/src/flash/nor/dsp5680xx_flash.c b/src/flash/nor/dsp5680xx_flash.c
index f06f143..ed09849 100644
--- a/src/flash/nor/dsp5680xx_flash.c
+++ b/src/flash/nor/dsp5680xx_flash.c
@@ -119,7 +119,7 @@ static int dsp5680xx_flash_protect_check(struct flash_bank 
*bank)
  *
  * @return
  */
-static int dsp5680xx_flash_protect(struct flash_bank *bank, int set,
+static int dsp5680xx_flash_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
 /**
diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c
index 2c323b0..4f214ed 100644
--- a/src/flash/nor/efm32.c
+++ b/src/flash/nor/efm32.c
@@ -599,7 +599,7 @@ static int efm32x_get_page_lock(struct flash_bank *bank, 
size_t page)
        return (dw & mask) ? 0 : 1;
 }
 
-static int efm32x_set_page_lock(struct flash_bank *bank, size_t page, int set)
+static int efm32x_set_page_lock(struct flash_bank *bank, size_t page, bool set)
 {
        struct efm32x_flash_bank *efm32x_info = bank->driver_priv;
        uint32_t *dw = &efm32x_info->lb_page[page >> 5];
@@ -615,7 +615,7 @@ static int efm32x_set_page_lock(struct flash_bank *bank, 
size_t page, int set)
        return ERROR_OK;
 }
 
-static int efm32x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int efm32x_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/em357.c b/src/flash/nor/em357.c
index 4e40e6b..7c5b953 100644
--- a/src/flash/nor/em357.c
+++ b/src/flash/nor/em357.c
@@ -393,7 +393,7 @@ static int em357_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int em357_protect(struct flash_bank *bank, int set, unsigned int first,
+static int em357_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct em357_flash_bank *em357_info = NULL;
diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c
index 6b2793f..65eeaf4 100644
--- a/src/flash/nor/fespi.c
+++ b/src/flash/nor/fespi.c
@@ -424,7 +424,7 @@ done:
        return retval;
 }
 
-static int fespi_protect(struct flash_bank *bank, int set,
+static int fespi_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/imp.h b/src/flash/nor/imp.h
index 06fb2a2..f4388f3 100644
--- a/src/flash/nor/imp.h
+++ b/src/flash/nor/imp.h
@@ -39,7 +39,7 @@ struct flash_bank *flash_bank_list(void);
 
 int flash_driver_erase(struct flash_bank *bank, unsigned int first,
                unsigned int last);
-int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
+int flash_driver_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last);
 int flash_driver_write(struct flash_bank *bank,
                uint8_t *buffer, uint32_t offset, uint32_t count);
diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c
index 20362f3..da4937d 100644
--- a/src/flash/nor/jtagspi.c
+++ b/src/flash/nor/jtagspi.c
@@ -363,7 +363,7 @@ static int jtagspi_erase(struct flash_bank *bank, unsigned 
int first,
        return retval;
 }
 
-static int jtagspi_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int jtagspi_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
index 07c5eac..1164b8b 100644
--- a/src/flash/nor/kinetis.c
+++ b/src/flash/nor/kinetis.c
@@ -1336,7 +1336,7 @@ static int kinetis_write_block(struct flash_bank *bank, 
const uint8_t *buffer,
        return retval;
 }
 
-static int kinetis_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int kinetis_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        if (allow_fcf_writes) {
diff --git a/src/flash/nor/kinetis_ke.c b/src/flash/nor/kinetis_ke.c
index 206d6f7..7bc0516 100644
--- a/src/flash/nor/kinetis_ke.c
+++ b/src/flash/nor/kinetis_ke.c
@@ -764,7 +764,7 @@ static int kinetis_ke_write_words(struct flash_bank *bank, 
const uint8_t *buffer
        return retval;
 }
 
-static int kinetis_ke_protect(struct flash_bank *bank, int set,
+static int kinetis_ke_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        LOG_WARNING("kinetis_ke_protect not supported yet");
diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c
index 13450ef..892bb1b 100644
--- a/src/flash/nor/lpc288x.c
+++ b/src/flash/nor/lpc288x.c
@@ -378,7 +378,7 @@ static int lpc288x_probe(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int lpc288x_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int lpc288x_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        int status;
diff --git a/src/flash/nor/lpcspifi.c b/src/flash/nor/lpcspifi.c
index dd1c63d..8ed1daf 100644
--- a/src/flash/nor/lpcspifi.c
+++ b/src/flash/nor/lpcspifi.c
@@ -570,7 +570,7 @@ static int lpcspifi_erase(struct flash_bank *bank, unsigned 
int first,
        return retval;
 }
 
-static int lpcspifi_protect(struct flash_bank *bank, int set,
+static int lpcspifi_protect(struct flash_bank *bank, bool set,
        unsigned int first, unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c
index 65898cd..210ebd3 100644
--- a/src/flash/nor/max32xxx.c
+++ b/src/flash/nor/max32xxx.c
@@ -321,7 +321,7 @@ static int max32xxx_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int max32xxx_protect(struct flash_bank *bank, int set,
+static int max32xxx_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        struct max32xxx_flash_bank *info = bank->driver_priv;
diff --git a/src/flash/nor/niietcm4.c b/src/flash/nor/niietcm4.c
index 0854038..117e765 100644
--- a/src/flash/nor/niietcm4.c
+++ b/src/flash/nor/niietcm4.c
@@ -331,7 +331,7 @@ static int niietcm4_uflash_page_erase(struct flash_bank 
*bank, int page_num, int
  * Enable or disable protection of userflash pages
  */
 static int niietcm4_uflash_protect(struct flash_bank *bank, int mem_type,
-               int set, unsigned int first, unsigned int last)
+               bool set, unsigned int first, unsigned int last)
 {
        int retval;
        if (mem_type == INFO_MEM_TYPE) {
@@ -692,15 +692,15 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_command)
        COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], first);
        COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], last);
 
-       int set;
+       bool set;
        if (strcmp("on", CMD_ARGV[3]) == 0) {
                command_print(CMD, "Try to enable %s userflash sectors %u 
through %u protection. Please wait ... ",
                                                                CMD_ARGV[0], 
first, last);
-               set = 1;
+               set = true;
        } else if (strcmp("off", CMD_ARGV[3]) == 0) {
                command_print(CMD, "Try to disable %s userflash sectors %u 
through %u protection. Please wait ... ",
                                                                CMD_ARGV[0], 
first, last);
-               set = 0;
+               set = false;
        } else
                return ERROR_COMMAND_SYNTAX_ERROR;
 
@@ -1213,7 +1213,7 @@ static int niietcm4_erase(struct flash_bank *bank, 
unsigned int first,
        return retval;
 }
 
-static int niietcm4_protect(struct flash_bank *bank, int set,
+static int niietcm4_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/nrf5.c b/src/flash/nor/nrf5.c
index a79aa78..a4de36a 100644
--- a/src/flash/nor/nrf5.c
+++ b/src/flash/nor/nrf5.c
@@ -512,7 +512,7 @@ static int nrf5_protect_check(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int nrf5_protect(struct flash_bank *bank, int set, unsigned int first,
+static int nrf5_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        int res;
diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c
index b214642..dcf1f70 100644
--- a/src/flash/nor/pic32mx.c
+++ b/src/flash/nor/pic32mx.c
@@ -359,19 +359,6 @@ static int pic32mx_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int pic32mx_protect(struct flash_bank *bank, int set, unsigned int 
first,
-               unsigned int last)
-{
-       struct target *target = bank->target;
-
-       if (target->state != TARGET_HALTED) {
-               LOG_ERROR("Target not halted");
-               return ERROR_TARGET_NOT_HALTED;
-       }
-
-       return ERROR_OK;
-}
-
 /* see contib/loaders/flash/pic32mx.s for src */
 
 static uint32_t pic32mx_flash_write_code[] = {
@@ -972,7 +959,6 @@ const struct flash_driver pic32mx_flash = {
        .commands = pic32mx_command_handlers,
        .flash_bank_command = pic32mx_flash_bank_command,
        .erase = pic32mx_erase,
-       .protect = pic32mx_protect,
        .write = pic32mx_write,
        .read = default_flash_read,
        .probe = pic32mx_probe,
diff --git a/src/flash/nor/psoc4.c b/src/flash/nor/psoc4.c
index be9a886..1bd5490 100644
--- a/src/flash/nor/psoc4.c
+++ b/src/flash/nor/psoc4.c
@@ -551,7 +551,7 @@ static int psoc4_erase(struct flash_bank *bank, unsigned 
int first,
 }
 
 
-static int psoc4_protect(struct flash_bank *bank, int set, unsigned int first,
+static int psoc4_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/psoc6.c b/src/flash/nor/psoc6.c
index 3eb2fc2..483691f 100644
--- a/src/flash/nor/psoc6.c
+++ b/src/flash/nor/psoc6.c
@@ -460,7 +460,7 @@ static int psoc6_protect_check(struct flash_bank *bank)
  * @brief Dummy function, Life Cycle transition is not currently supported
  * @return ERROR_OK always
  
*************************************************************************************************/
-static int psoc6_protect(struct flash_bank *bank, int set, unsigned int first,
+static int psoc6_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        (void)bank;
diff --git a/src/flash/nor/sh_qspi.c b/src/flash/nor/sh_qspi.c
index 1ba9753..ed66f4b 100644
--- a/src/flash/nor/sh_qspi.c
+++ b/src/flash/nor/sh_qspi.c
@@ -683,7 +683,7 @@ static int read_flash_id(struct flash_bank *bank, uint32_t 
*id)
        return ERROR_OK;
 }
 
-static int sh_qspi_protect(struct flash_bank *bank, int set,
+static int sh_qspi_protect(struct flash_bank *bank, bool set,
                         unsigned int first, unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/sim3x.c b/src/flash/nor/sim3x.c
index d2d254e..8794600 100644
--- a/src/flash/nor/sim3x.c
+++ b/src/flash/nor/sim3x.c
@@ -569,7 +569,7 @@ static int sim3x_flash_protect_check(struct flash_bank 
*bank)
        return ERROR_OK;
 }
 
-static int sim3x_flash_protect(struct flash_bank *bank, int set,
+static int sim3x_flash_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        int ret;
diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c
index 9763644..9db696a 100644
--- a/src/flash/nor/stellaris.c
+++ b/src/flash/nor/stellaris.c
@@ -901,7 +901,7 @@ static int stellaris_erase(struct flash_bank *bank, 
unsigned int first,
        return ERROR_OK;
 }
 
-static int stellaris_protect(struct flash_bank *bank, int set,
+static int stellaris_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        struct stellaris_flash_bank *stellaris = bank->driver_priv;
diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c
index a07bd84..c777704 100644
--- a/src/flash/nor/stm32f1x.c
+++ b/src/flash/nor/stm32f1x.c
@@ -413,7 +413,7 @@ static int stm32x_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int stm32x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int stm32x_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c
index c00b423..5d0ee89 100644
--- a/src/flash/nor/stm32f2x.c
+++ b/src/flash/nor/stm32f2x.c
@@ -660,7 +660,7 @@ static int stm32x_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int stm32x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int stm32x_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/stm32h7x.c b/src/flash/nor/stm32h7x.c
index 72bfa5f..8f71064 100644
--- a/src/flash/nor/stm32h7x.c
+++ b/src/flash/nor/stm32h7x.c
@@ -504,7 +504,7 @@ flash_lock:
        return (retval == ERROR_OK) ? retval2 : retval;
 }
 
-static int stm32x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int stm32x_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c
index edd0130..dbf79cc 100644
--- a/src/flash/nor/stm32l4x.c
+++ b/src/flash/nor/stm32l4x.c
@@ -631,7 +631,7 @@ err_lock:
        return retval2;
 }
 
-static int stm32l4_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int stm32l4_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct target *target = bank->target;
@@ -646,7 +646,7 @@ static int stm32l4_protect(struct flash_bank *bank, int 
set, unsigned int first,
        /* Bank 2 */
        uint32_t reg_value = 0xFF; /* Default to bank un-protected */
        if (last >= stm32l4_info->bank1_sectors) {
-               if (set == 1) {
+               if (set) {
                        uint8_t begin = first > stm32l4_info->bank1_sectors ? 
first : 0x00;
                        reg_value = ((last & 0xFF) << 16) | begin;
                }
@@ -656,7 +656,7 @@ static int stm32l4_protect(struct flash_bank *bank, int 
set, unsigned int first,
        /* Bank 1 */
        reg_value = 0xFF; /* Default to bank un-protected */
        if (first < stm32l4_info->bank1_sectors) {
-               if (set == 1) {
+               if (set) {
                        uint8_t end = last >= stm32l4_info->bank1_sectors ? 
0xFF : last;
                        reg_value = (end << 16) | (first & 0xFF);
                }
diff --git a/src/flash/nor/stmsmi.c b/src/flash/nor/stmsmi.c
index 278c73e..357ab4d 100644
--- a/src/flash/nor/stmsmi.c
+++ b/src/flash/nor/stmsmi.c
@@ -360,7 +360,7 @@ static int stmsmi_erase(struct flash_bank *bank, unsigned 
int first,
        return retval;
 }
 
-static int stmsmi_protect(struct flash_bank *bank, int set,
+static int stmsmi_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        for (unsigned int sector = first; sector <= last; sector++)
diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index dd72f53..7c29782 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -382,7 +382,7 @@ static int str7x_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int str7x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int str7x_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct str7x_flash_bank *str7x_info = bank->driver_priv;
diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c
index d49875c..0f527b2 100644
--- a/src/flash/nor/str9x.c
+++ b/src/flash/nor/str9x.c
@@ -306,7 +306,7 @@ static int str9x_erase(struct flash_bank *bank, unsigned 
int first,
        return ERROR_OK;
 }
 
-static int str9x_protect(struct flash_bank *bank, int set, unsigned int first,
+static int str9x_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        struct target *target = bank->target;
diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c
index 9946b06..60d6301 100644
--- a/src/flash/nor/str9xpec.c
+++ b/src/flash/nor/str9xpec.c
@@ -505,7 +505,7 @@ static int str9xpec_unlock_device(struct flash_bank *bank)
        return status;
 }
 
-static int str9xpec_protect(struct flash_bank *bank, int set,
+static int str9xpec_protect(struct flash_bank *bank, bool set,
                unsigned int first, unsigned int last)
 {
        uint8_t status;
diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c
index 0d3f487..90e445b 100644
--- a/src/flash/nor/tms470.c
+++ b/src/flash/nor/tms470.c
@@ -841,7 +841,7 @@ static int tms470_erase(struct flash_bank *bank, unsigned 
int first,
 
 /* ---------------------------------------------------------------------- */
 
-static int tms470_protect(struct flash_bank *bank, int set, unsigned int first,
+static int tms470_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct tms470_flash_bank *tms470_info = bank->driver_priv;
@@ -872,11 +872,11 @@ static int tms470_protect(struct flash_bank *bank, int 
set, unsigned int first,
        for (unsigned int sector = 0; sector < bank->num_sectors; sector++) {
                if (sector < 16) {
                        fmbsea = set ? fmbsea & ~(1 << sector) : fmbsea | (1 << 
sector);
-                       bank->sectors[sector].is_protected = set ? 1 : 0;
+                       bank->sectors[sector].is_protected = set;
                } else {
                        fmbseb = set ? fmbseb &
                                ~(1 << (sector - 16)) : fmbseb | (1 << (sector 
- 16));
-                       bank->sectors[sector].is_protected = set ? 1 : 0;
+                       bank->sectors[sector].is_protected = set;
                }
        }
 
diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c
index c9e1942..5094d0a 100644
--- a/src/flash/nor/virtual.c
+++ b/src/flash/nor/virtual.c
@@ -75,7 +75,7 @@ FLASH_BANK_COMMAND_HANDLER(virtual_flash_bank_command)
        return ERROR_OK;
 }
 
-static int virtual_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int virtual_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c
index ded5e5e..d48b0b4 100644
--- a/src/flash/nor/xcf.c
+++ b/src/flash/nor/xcf.c
@@ -730,7 +730,7 @@ static int xcf_write(struct flash_bank *bank, const uint8_t 
*buffer, uint32_t of
        return read_write_data(bank, buffer, NULL, true, offset, count);
 }
 
-static int xcf_protect(struct flash_bank *bank, int set, unsigned int first,
+static int xcf_protect(struct flash_bank *bank, bool set, unsigned int first,
                unsigned int last)
 {
        int ret;
diff --git a/src/flash/nor/xmc4xxx.c b/src/flash/nor/xmc4xxx.c
index aa26693..3495aca 100644
--- a/src/flash/nor/xmc4xxx.c
+++ b/src/flash/nor/xmc4xxx.c
@@ -1145,7 +1145,7 @@ static int xmc4xxx_flash_protect(struct flash_bank *bank, 
int level, bool read_p
        return ERROR_OK;
 }
 
-static int xmc4xxx_protect(struct flash_bank *bank, int set, unsigned int 
first,
+static int xmc4xxx_protect(struct flash_bank *bank, bool set, unsigned int 
first,
                unsigned int last)
 {
        int ret;
@@ -1158,7 +1158,7 @@ static int xmc4xxx_protect(struct flash_bank *bank, int 
set, unsigned int first,
        }
 
        /* We want to clear flash protection temporarily*/
-       if (set == 0) {
+       if (!set) {
                LOG_WARNING("Flash protection will be temporarily disabled"
                            " for all pages (User 0 only)!");
                ret = xmc4xxx_temp_unprotect(bank, 0);

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to