Constify struct flash_driver instances 03/4803/3
authorChristopher Head <chead@zaber.com>
Thu, 13 Dec 2018 19:53:59 +0000 (11:53 -0800)
committerMatthias Welwarsky <matthias@welwarsky.de>
Wed, 27 Mar 2019 08:57:14 +0000 (08:57 +0000)
Instances of struct flash_driver are never written to at runtime. For a
small amount of memory saving and also robustness (fewer things for
stray pointer writes to hit), mark them const.

Change-Id: Iadbbbc2fac0976d892699200000c5f02856729f3
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4803
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
64 files changed:
src/flash/nor/aduc702x.c
src/flash/nor/aducm360.c
src/flash/nor/ambiqmicro.c
src/flash/nor/at91sam3.c
src/flash/nor/at91sam4.c
src/flash/nor/at91sam4l.c
src/flash/nor/at91sam7.c
src/flash/nor/at91samd.c
src/flash/nor/ath79.c
src/flash/nor/atsame5.c
src/flash/nor/atsamv.c
src/flash/nor/avrf.c
src/flash/nor/bluenrg-x.c
src/flash/nor/cc26xx.c
src/flash/nor/cc3220sf.c
src/flash/nor/cfi.c
src/flash/nor/core.h
src/flash/nor/driver.h
src/flash/nor/drivers.c
src/flash/nor/dsp5680xx_flash.c
src/flash/nor/efm32.c
src/flash/nor/em357.c
src/flash/nor/esirisc_flash.c
src/flash/nor/faux.c
src/flash/nor/fespi.c
src/flash/nor/fm3.c
src/flash/nor/fm4.c
src/flash/nor/jtagspi.c
src/flash/nor/kinetis.c
src/flash/nor/kinetis_ke.c
src/flash/nor/lpc2000.c
src/flash/nor/lpc288x.c
src/flash/nor/lpc2900.c
src/flash/nor/lpcspifi.c
src/flash/nor/max32xxx.c
src/flash/nor/mdr.c
src/flash/nor/mrvlqspi.c
src/flash/nor/msp432.c
src/flash/nor/niietcm4.c
src/flash/nor/nrf5.c
src/flash/nor/numicro.c
src/flash/nor/ocl.c
src/flash/nor/pic32mx.c
src/flash/nor/psoc4.c
src/flash/nor/psoc5lp.c
src/flash/nor/psoc6.c
src/flash/nor/sim3x.c
src/flash/nor/stellaris.c
src/flash/nor/stm32f1x.c
src/flash/nor/stm32f2x.c
src/flash/nor/stm32h7x.c
src/flash/nor/stm32l4x.c
src/flash/nor/stm32lx.c
src/flash/nor/stmsmi.c
src/flash/nor/str7x.c
src/flash/nor/str9x.c
src/flash/nor/str9xpec.c
src/flash/nor/tcl.c
src/flash/nor/tms470.c
src/flash/nor/virtual.c
src/flash/nor/w600.c
src/flash/nor/xcf.c
src/flash/nor/xmc1xxx.c
src/flash/nor/xmc4xxx.c

index 824112b..b6e1937 100644 (file)
@@ -378,7 +378,7 @@ static int aduc702x_check_flash_completion(struct target *target, unsigned int t
                return ERROR_OK;
 }
 
-struct flash_driver aduc702x_flash = {
+const struct flash_driver aduc702x_flash = {
        .name = "aduc702x",
        .flash_bank_command = aduc702x_flash_bank_command,
        .erase = aduc702x_erase,
index 7663783..f468c89 100644 (file)
@@ -554,7 +554,7 @@ static int aducm360_check_flash_completion(struct target *target, unsigned int t
 }
 
 /* ----------------------------------------------------------------------- */
-struct flash_driver aducm360_flash = {
+const struct flash_driver aducm360_flash = {
        .name = "aducm360",
        .flash_bank_command = aducm360_flash_bank_command,
        .erase = aducm360_erase,
index 13b2b26..a536d54 100644 (file)
@@ -888,7 +888,7 @@ static const struct command_registration ambiqmicro_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver ambiqmicro_flash = {
+const struct flash_driver ambiqmicro_flash = {
        .name = "ambiqmicro",
        .commands = ambiqmicro_command_handlers,
        .flash_bank_command = ambiqmicro_flash_bank_command,
index 7119188..2d61a87 100644 (file)
 #define  offset_EFC_FSR   8
 #define  offset_EFC_FRR   12
 
-extern struct flash_driver at91sam3_flash;
+extern const struct flash_driver at91sam3_flash;
 
 static float _tomhz(uint32_t freq_hz)
 {
@@ -3753,7 +3753,7 @@ static const struct command_registration at91sam3_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver at91sam3_flash = {
+const struct flash_driver at91sam3_flash = {
        .name = "at91sam3",
        .commands = at91sam3_command_handlers,
        .flash_bank_command = sam3_flash_bank_command,
index d4d48a7..446f798 100644 (file)
 #define  offset_EFC_FSR   8
 #define  offset_EFC_FRR   12
 
-extern struct flash_driver at91sam4_flash;
+extern const struct flash_driver at91sam4_flash;
 
 static float _tomhz(uint32_t freq_hz)
 {
@@ -3234,7 +3234,7 @@ static const struct command_registration at91sam4_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver at91sam4_flash = {
+const struct flash_driver at91sam4_flash = {
        .name = "at91sam4",
        .commands = at91sam4_command_handlers,
        .flash_bank_command = sam4_flash_bank_command,
index f3b065f..1c2402f 100644 (file)
@@ -684,7 +684,7 @@ static const struct command_registration at91sam4l_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver at91sam4l_flash = {
+const struct flash_driver at91sam4l_flash = {
        .name = "at91sam4l",
        .commands = at91sam4l_command_handlers,
        .flash_bank_command = sam4l_flash_bank_command,
index 9de8293..15b93a2 100644 (file)
@@ -1140,7 +1140,7 @@ static const struct command_registration at91sam7_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver at91sam7_flash = {
+const struct flash_driver at91sam7_flash = {
        .name = "at91sam7",
        .usage = "gpnvm <bit> <set | clear>",
        .commands = at91sam7_command_handlers,
index 029579b..ad0da5d 100644 (file)
@@ -1287,7 +1287,7 @@ static const struct command_registration at91samd_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver at91samd_flash = {
+const struct flash_driver at91samd_flash = {
        .name = "at91samd",
        .commands = at91samd_command_handlers,
        .flash_bank_command = samd_flash_bank_command,
index af2112a..c551f27 100644 (file)
@@ -895,7 +895,7 @@ static int get_ath79_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver ath79_flash = {
+const struct flash_driver ath79_flash = {
        .name = "ath79",
        .flash_bank_command = ath79_flash_bank_command,
        .erase = ath79_erase,
index ff99e7d..833177e 100644 (file)
@@ -938,7 +938,7 @@ static const struct command_registration same5_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver atsame5_flash = {
+const struct flash_driver atsame5_flash = {
        .name = "atsame5",
        .commands = same5_command_handlers,
        .flash_bank_command = same5_flash_bank_command,
index 9c07bdf..5beeefc 100644 (file)
@@ -94,7 +94,7 @@
 #define SAMV_PAGE_SIZE                 512
 #define SAMV_FLASH_BASE         0x00400000
 
-extern struct flash_driver atsamv_flash;
+extern const struct flash_driver atsamv_flash;
 
 struct samv_flash_bank {
        int      probed;
@@ -726,7 +726,7 @@ static const struct command_registration atsamv_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver atsamv_flash = {
+const struct flash_driver atsamv_flash = {
        .name = "atsamv",
        .commands = atsamv_command_handlers,
        .flash_bank_command = samv_flash_bank_command,
index b88f6f6..6969f77 100644 (file)
@@ -462,7 +462,7 @@ static const struct command_registration avrf_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver avr_flash = {
+const struct flash_driver avr_flash = {
        .name = "avr",
        .commands = avrf_command_handlers,
        .flash_bank_command = avrf_flash_bank_command,
index f1b2062..f6a2492 100644 (file)
@@ -539,7 +539,7 @@ static int bluenrgx_get_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver bluenrgx_flash = {
+const struct flash_driver bluenrgx_flash = {
        .name = "bluenrg-x",
        .flash_bank_command = bluenrgx_flash_bank_command,
        .erase = bluenrgx_erase,
index 0320e92..176211a 100644 (file)
@@ -535,7 +535,7 @@ static int cc26xx_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver cc26xx_flash = {
+const struct flash_driver cc26xx_flash = {
        .name = "cc26xx",
        .flash_bank_command = cc26xx_flash_bank_command,
        .erase = cc26xx_erase,
index 2441124..afdb7f4 100644 (file)
@@ -489,7 +489,7 @@ static int cc3220sf_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver cc3220sf_flash = {
+const struct flash_driver cc3220sf_flash = {
        .name = "cc3220sf",
        .flash_bank_command = cc3220sf_flash_bank_command,
        .erase = cc3220sf_erase,
index 1638628..04fa83b 100644 (file)
@@ -3112,7 +3112,7 @@ static void cfi_fixup_0002_write_buffer(struct flash_bank *bank, const void *par
        cfi_info->buf_write_timeout_typ = 0;
 }
 
-struct flash_driver cfi_flash = {
+const struct flash_driver cfi_flash = {
        .name = "cfi",
        .flash_bank_command = cfi_flash_bank_command,
        .erase = cfi_erase,
index bd3aa70..f6bd0cf 100644 (file)
@@ -87,7 +87,7 @@ struct flash_bank {
 
        struct target *target; /**< Target to which this bank belongs. */
 
-       struct flash_driver *driver; /**< Driver for this bank. */
+       const struct flash_driver *driver; /**< Driver for this bank. */
        void *driver_priv; /**< Private driver storage pointer */
 
        int bank_number; /**< The 'bank' (or chip number) of this instance. */
index ef69a0f..9c56d4e 100644 (file)
@@ -231,6 +231,6 @@ struct flash_driver {
  * @param name The name of the requested driver.
  * @returns The flash_driver called @c name, or NULL if not found.
  */
-struct flash_driver *flash_driver_find_by_name(const char *name);
+const struct flash_driver *flash_driver_find_by_name(const char *name);
 
 #endif /* OPENOCD_FLASH_NOR_DRIVER_H */
index 31caa5a..955d149 100644 (file)
 #endif
 #include "imp.h"
 
-extern struct flash_driver aduc702x_flash;
-extern struct flash_driver aducm360_flash;
-extern struct flash_driver ambiqmicro_flash;
-extern struct flash_driver at91sam3_flash;
-extern struct flash_driver at91sam4_flash;
-extern struct flash_driver at91sam4l_flash;
-extern struct flash_driver at91sam7_flash;
-extern struct flash_driver at91samd_flash;
-extern struct flash_driver ath79_flash;
-extern struct flash_driver atsame5_flash;
-extern struct flash_driver atsamv_flash;
-extern struct flash_driver avr_flash;
-extern struct flash_driver bluenrgx_flash;
-extern struct flash_driver cc3220sf_flash;
-extern struct flash_driver cc26xx_flash;
-extern struct flash_driver cfi_flash;
-extern struct flash_driver dsp5680xx_flash;
-extern struct flash_driver efm32_flash;
-extern struct flash_driver em357_flash;
-extern struct flash_driver esirisc_flash;
-extern struct flash_driver faux_flash;
-extern struct flash_driver fm3_flash;
-extern struct flash_driver fm4_flash;
-extern struct flash_driver fespi_flash;
-extern struct flash_driver jtagspi_flash;
-extern struct flash_driver kinetis_flash;
-extern struct flash_driver kinetis_ke_flash;
-extern struct flash_driver lpc2000_flash;
-extern struct flash_driver lpc288x_flash;
-extern struct flash_driver lpc2900_flash;
-extern struct flash_driver lpcspifi_flash;
-extern struct flash_driver max32xxx_flash;
-extern struct flash_driver mdr_flash;
-extern struct flash_driver mrvlqspi_flash;
-extern struct flash_driver msp432_flash;
-extern struct flash_driver niietcm4_flash;
-extern struct flash_driver nrf5_flash;
-extern struct flash_driver nrf51_flash;
-extern struct flash_driver numicro_flash;
-extern struct flash_driver ocl_flash;
-extern struct flash_driver pic32mx_flash;
-extern struct flash_driver psoc4_flash;
-extern struct flash_driver psoc5lp_flash;
-extern struct flash_driver psoc5lp_eeprom_flash;
-extern struct flash_driver psoc5lp_nvl_flash;
-extern struct flash_driver psoc6_flash;
-extern struct flash_driver sim3x_flash;
-extern struct flash_driver stellaris_flash;
-extern struct flash_driver stm32f1x_flash;
-extern struct flash_driver stm32f2x_flash;
-extern struct flash_driver stm32lx_flash;
-extern struct flash_driver stm32l4x_flash;
-extern struct flash_driver stm32h7x_flash;
-extern struct flash_driver stmsmi_flash;
-extern struct flash_driver str7x_flash;
-extern struct flash_driver str9x_flash;
-extern struct flash_driver str9xpec_flash;
-extern struct flash_driver tms470_flash;
-extern struct flash_driver virtual_flash;
-extern struct flash_driver w600_flash;
-extern struct flash_driver xcf_flash;
-extern struct flash_driver xmc1xxx_flash;
-extern struct flash_driver xmc4xxx_flash;
+extern const struct flash_driver aduc702x_flash;
+extern const struct flash_driver aducm360_flash;
+extern const struct flash_driver ambiqmicro_flash;
+extern const struct flash_driver at91sam3_flash;
+extern const struct flash_driver at91sam4_flash;
+extern const struct flash_driver at91sam4l_flash;
+extern const struct flash_driver at91sam7_flash;
+extern const struct flash_driver at91samd_flash;
+extern const struct flash_driver ath79_flash;
+extern const struct flash_driver atsame5_flash;
+extern const struct flash_driver atsamv_flash;
+extern const struct flash_driver avr_flash;
+extern const struct flash_driver bluenrgx_flash;
+extern const struct flash_driver cc3220sf_flash;
+extern const struct flash_driver cc26xx_flash;
+extern const struct flash_driver cfi_flash;
+extern const struct flash_driver dsp5680xx_flash;
+extern const struct flash_driver efm32_flash;
+extern const struct flash_driver em357_flash;
+extern const struct flash_driver esirisc_flash;
+extern const struct flash_driver faux_flash;
+extern const struct flash_driver fm3_flash;
+extern const struct flash_driver fm4_flash;
+extern const struct flash_driver fespi_flash;
+extern const struct flash_driver jtagspi_flash;
+extern const struct flash_driver kinetis_flash;
+extern const struct flash_driver kinetis_ke_flash;
+extern const struct flash_driver lpc2000_flash;
+extern const struct flash_driver lpc288x_flash;
+extern const struct flash_driver lpc2900_flash;
+extern const struct flash_driver lpcspifi_flash;
+extern const struct flash_driver max32xxx_flash;
+extern const struct flash_driver mdr_flash;
+extern const struct flash_driver mrvlqspi_flash;
+extern const struct flash_driver msp432_flash;
+extern const struct flash_driver niietcm4_flash;
+extern const struct flash_driver nrf5_flash;
+extern const struct flash_driver nrf51_flash;
+extern const struct flash_driver numicro_flash;
+extern const struct flash_driver ocl_flash;
+extern const struct flash_driver pic32mx_flash;
+extern const struct flash_driver psoc4_flash;
+extern const struct flash_driver psoc5lp_flash;
+extern const struct flash_driver psoc5lp_eeprom_flash;
+extern const struct flash_driver psoc5lp_nvl_flash;
+extern const struct flash_driver psoc6_flash;
+extern const struct flash_driver sim3x_flash;
+extern const struct flash_driver stellaris_flash;
+extern const struct flash_driver stm32f1x_flash;
+extern const struct flash_driver stm32f2x_flash;
+extern const struct flash_driver stm32lx_flash;
+extern const struct flash_driver stm32l4x_flash;
+extern const struct flash_driver stm32h7x_flash;
+extern const struct flash_driver stmsmi_flash;
+extern const struct flash_driver str7x_flash;
+extern const struct flash_driver str9x_flash;
+extern const struct flash_driver str9xpec_flash;
+extern const struct flash_driver tms470_flash;
+extern const struct flash_driver virtual_flash;
+extern const struct flash_driver w600_flash;
+extern const struct flash_driver xcf_flash;
+extern const struct flash_driver xmc1xxx_flash;
+extern const struct flash_driver xmc4xxx_flash;
 
 /**
  * The list of built-in flash drivers.
  * @todo Make this dynamically extendable with loadable modules.
  */
-static struct flash_driver *flash_drivers[] = {
+static const struct flash_driver * const flash_drivers[] = {
        &aduc702x_flash,
        &aducm360_flash,
        &ambiqmicro_flash,
@@ -155,7 +155,7 @@ static struct flash_driver *flash_drivers[] = {
        NULL,
 };
 
-struct flash_driver *flash_driver_find_by_name(const char *name)
+const struct flash_driver *flash_driver_find_by_name(const char *name)
 {
        for (unsigned i = 0; flash_drivers[i]; i++) {
                if (strcmp(name, flash_drivers[i]->name) == 0)
index 38649ff..37b60f0 100644 (file)
@@ -256,7 +256,7 @@ static int dsp5680xx_flash_erase_check(struct flash_bank *bank)
        return retval;
 }
 
-struct flash_driver dsp5680xx_flash = {
+const struct flash_driver dsp5680xx_flash = {
        .name = "dsp5680xx_flash",
        .flash_bank_command = dsp5680xx_flash_bank_command,
        .erase = dsp5680xx_flash_erase,
index 8ff689c..d2ac3a8 100644 (file)
@@ -1120,7 +1120,7 @@ static const struct command_registration efm32x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver efm32_flash = {
+const struct flash_driver efm32_flash = {
        .name = "efm32",
        .commands = efm32x_command_handlers,
        .flash_bank_command = efm32x_flash_bank_command,
index b14e032..e6b2728 100644 (file)
@@ -929,7 +929,7 @@ static const struct command_registration em357_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver em357_flash = {
+const struct flash_driver em357_flash = {
        .name = "em357",
        .commands = em357_command_handlers,
        .flash_bank_command = em357_flash_bank_command,
index 9e11571..948d001 100644 (file)
@@ -571,7 +571,7 @@ static const struct command_registration esirisc_flash_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver esirisc_flash = {
+const struct flash_driver esirisc_flash = {
        .name = "esirisc",
        .usage = "flash bank bank_id 'esirisc' base_address size_bytes 0 0 target "
                        "cfg_address clock_hz wait_states",
index d68940f..49b6dcc 100644 (file)
@@ -113,7 +113,7 @@ static const struct command_registration faux_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver faux_flash = {
+const struct flash_driver faux_flash = {
        .name = "faux",
        .commands = faux_command_handlers,
        .flash_bank_command = faux_flash_bank_command,
index ea47afd..1c343a8 100644 (file)
@@ -1038,7 +1038,7 @@ static int get_fespi_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver fespi_flash = {
+const struct flash_driver fespi_flash = {
        .name = "fespi",
        .flash_bank_command = fespi_flash_bank_command,
        .erase = fespi_erase,
index 6c61977..f2da2af 100644 (file)
@@ -988,7 +988,7 @@ static const struct command_registration fm3_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver fm3_flash = {
+const struct flash_driver fm3_flash = {
        .name = "fm3",
        .commands = fm3_command_handlers,
        .flash_bank_command = fm3_flash_bank_command,
index 171cbd7..a8877b4 100644 (file)
@@ -702,7 +702,7 @@ static const struct command_registration fm4_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver fm4_flash = {
+const struct flash_driver fm4_flash = {
        .name = "fm4",
        .commands = fm4_command_handlers,
        .flash_bank_command = fm4_flash_bank_command,
index 0750fdf..a9f2dd4 100644 (file)
@@ -427,7 +427,7 @@ static int jtagspi_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver jtagspi_flash = {
+const struct flash_driver jtagspi_flash = {
        .name = "jtagspi",
        .flash_bank_command = jtagspi_flash_bank_command,
        .erase = jtagspi_erase,
index d827355..22c5d5c 100644 (file)
@@ -393,7 +393,7 @@ static bool fcf_fopt_configured;
 static bool create_banks;
 
 
-struct flash_driver kinetis_flash;
+const struct flash_driver kinetis_flash;
 static int kinetis_write_inner(struct flash_bank *bank, const uint8_t *buffer,
                        uint32_t offset, uint32_t count);
 static int kinetis_probe_chip(struct kinetis_chip *k_chip);
@@ -3143,7 +3143,7 @@ static const struct command_registration kinetis_command_handler[] = {
 
 
 
-struct flash_driver kinetis_flash = {
+const struct flash_driver kinetis_flash = {
        .name = "kinetis",
        .commands = kinetis_command_handler,
        .flash_bank_command = kinetis_flash_bank_command,
index 9441a9d..27b6d3a 100644 (file)
@@ -1297,7 +1297,7 @@ static const struct command_registration kinetis_ke_command_handler[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver kinetis_ke_flash = {
+const struct flash_driver kinetis_ke_flash = {
        .name = "kinetis_ke",
        .commands = kinetis_ke_command_handler,
        .flash_bank_command = kinetis_ke_flash_bank_command,
index 58afd79..cb3f58e 100644 (file)
@@ -1609,7 +1609,7 @@ static const struct command_registration lpc2000_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver lpc2000_flash = {
+const struct flash_driver lpc2000_flash = {
        .name = "lpc2000",
        .commands = lpc2000_command_handlers,
        .flash_bank_command = lpc2000_flash_bank_command,
index afa8d79..8852c85 100644 (file)
@@ -412,7 +412,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,
index 022fb82..c798e44 100644 (file)
@@ -1581,7 +1581,7 @@ static int lpc2900_protect_check(struct flash_bank *bank)
        return lpc2900_read_security_status(bank);
 }
 
-struct flash_driver lpc2900_flash = {
+const struct flash_driver lpc2900_flash = {
        .name = "lpc2900",
        .commands = lpc2900_command_handlers,
        .flash_bank_command = lpc2900_flash_bank_command,
index a7e65ec..19d754b 100644 (file)
@@ -946,7 +946,7 @@ static int get_lpcspifi_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver lpcspifi_flash = {
+const struct flash_driver lpcspifi_flash = {
        .name = "lpcspifi",
        .flash_bank_command = lpcspifi_flash_bank_command,
        .erase = lpcspifi_erase,
index ca037de..12e3db9 100644 (file)
@@ -981,7 +981,7 @@ static const struct command_registration max32xxx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver max32xxx_flash = {
+const struct flash_driver max32xxx_flash = {
        .name = "max32xxx",
        .commands = max32xxx_command_handlers,
        .flash_bank_command = max32xxx_flash_bank_command,
index c4a4458..3796259 100644 (file)
@@ -609,7 +609,7 @@ static int get_mdr_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver mdr_flash = {
+const struct flash_driver mdr_flash = {
        .name = "mdr",
        .usage = "flash bank <name> mdr <base> <size> 0 0 <target#> <type> <page_count> <sec_count>\n"
        "<type>: 0 for main memory, 1 for info memory",
index cb2cfdb..803e84a 100644 (file)
@@ -953,7 +953,7 @@ FLASH_BANK_COMMAND_HANDLER(mrvlqspi_flash_bank_command)
        return ERROR_OK;
 }
 
-struct flash_driver mrvlqspi_flash = {
+const struct flash_driver mrvlqspi_flash = {
        .name = "mrvlqspi",
        .flash_bank_command = mrvlqspi_flash_bank_command,
        .erase = mrvlqspi_flash_erase,
index e2e65d4..e9e4be3 100644 (file)
@@ -1075,7 +1075,7 @@ static const struct command_registration msp432_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver msp432_flash = {
+const struct flash_driver msp432_flash = {
        .name = "msp432",
        .commands = msp432_command_handlers,
        .flash_bank_command = msp432_flash_bank_command,
index f2f4470..b034ee1 100644 (file)
@@ -1729,7 +1729,7 @@ static int get_niietcm4_info(struct flash_bank *bank, char *buf, int buf_size)
 }
 
 
-struct flash_driver niietcm4_flash = {
+const struct flash_driver niietcm4_flash = {
        .name = "niietcm4",
        .usage = "flash bank <name> niietcm4 <base> <size> 0 0 <target#>",
        .commands = niietcm4_command_handlers,
index 1e8dda3..aab80f9 100644 (file)
@@ -1140,7 +1140,7 @@ static const struct command_registration nrf5_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver nrf5_flash = {
+const struct flash_driver nrf5_flash = {
        .name                   = "nrf5",
        .commands               = nrf5_command_handlers,
        .flash_bank_command     = nrf5_flash_bank_command,
@@ -1158,7 +1158,7 @@ struct flash_driver nrf5_flash = {
 
 /* We need to retain the flash-driver name as well as the commands
  * for backwards compatability */
-struct flash_driver nrf51_flash = {
+const struct flash_driver nrf51_flash = {
        .name                   = "nrf51",
        .commands               = nrf5_command_handlers,
        .flash_bank_command     = nrf5_flash_bank_command,
index ebf9d53..8d8abd5 100644 (file)
@@ -1871,7 +1871,7 @@ static const struct command_registration numicro_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver numicro_flash = {
+const struct flash_driver numicro_flash = {
        .name = "numicro",
        .commands = numicro_command_handlers,
        .flash_bank_command = numicro_flash_bank_command,
index acc464b..d2a6594 100644 (file)
@@ -314,7 +314,7 @@ static int ocl_auto_probe(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-struct flash_driver ocl_flash = {
+const struct flash_driver ocl_flash = {
        .name = "ocl",
        .flash_bank_command = ocl_flash_bank_command,
        .erase = ocl_erase,
index 852a8bd..5ad4cb7 100644 (file)
@@ -967,7 +967,7 @@ static const struct command_registration pic32mx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver pic32mx_flash = {
+const struct flash_driver pic32mx_flash = {
        .name = "pic32mx",
        .commands = pic32mx_command_handlers,
        .flash_bank_command = pic32mx_flash_bank_command,
index 47d60de..0058f2d 100644 (file)
@@ -950,7 +950,7 @@ static const struct command_registration psoc4_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver psoc4_flash = {
+const struct flash_driver psoc4_flash = {
        .name = "psoc4",
        .commands = psoc4_command_handlers,
        .flash_bank_command = psoc4_flash_bank_command,
index 47567e7..66e2b07 100644 (file)
@@ -838,7 +838,7 @@ static const struct command_registration psoc5lp_nvl_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver psoc5lp_nvl_flash = {
+const struct flash_driver psoc5lp_nvl_flash = {
        .name = "psoc5lp_nvl",
        .commands = psoc5lp_nvl_command_handlers,
        .flash_bank_command = psoc5lp_nvl_flash_bank_command,
@@ -1036,7 +1036,7 @@ static const struct command_registration psoc5lp_eeprom_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver psoc5lp_eeprom_flash = {
+const struct flash_driver psoc5lp_eeprom_flash = {
        .name = "psoc5lp_eeprom",
        .commands = psoc5lp_eeprom_command_handlers,
        .flash_bank_command = psoc5lp_eeprom_flash_bank_command,
@@ -1548,7 +1548,7 @@ static const struct command_registration psoc5lp_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver psoc5lp_flash = {
+const struct flash_driver psoc5lp_flash = {
        .name = "psoc5lp",
        .commands = psoc5lp_command_handlers,
        .flash_bank_command = psoc5lp_flash_bank_command,
index 9352ad4..386075e 100644 (file)
@@ -1048,7 +1048,7 @@ static const struct command_registration psoc6_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver psoc6_flash = {
+const struct flash_driver psoc6_flash = {
        .name = "psoc6",
        .commands = psoc6_command_handlers,
        .flash_bank_command = psoc6_flash_bank_command,
index f282ba0..7ccf56b 100644 (file)
@@ -1110,7 +1110,7 @@ static const struct command_registration sim3x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver sim3x_flash = {
+const struct flash_driver sim3x_flash = {
        .name = "sim3x",
        .commands = sim3x_command_handlers,
        .flash_bank_command = sim3x_flash_bank_command,
index 8731f8b..6b6f6e8 100644 (file)
@@ -1441,7 +1441,7 @@ static const struct command_registration stellaris_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stellaris_flash = {
+const struct flash_driver stellaris_flash = {
        .name = "stellaris",
        .commands = stellaris_command_handlers,
        .flash_bank_command = stellaris_flash_bank_command,
index cd060da..d5d59c6 100644 (file)
@@ -1570,7 +1570,7 @@ static const struct command_registration stm32x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stm32f1x_flash = {
+const struct flash_driver stm32f1x_flash = {
        .name = "stm32f1x",
        .commands = stm32x_command_handlers,
        .flash_bank_command = stm32x_flash_bank_command,
index 63c8347..23f0030 100644 (file)
@@ -1792,7 +1792,7 @@ static const struct command_registration stm32x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stm32f2x_flash = {
+const struct flash_driver stm32f2x_flash = {
        .name = "stm32f2x",
        .commands = stm32x_command_handlers,
        .flash_bank_command = stm32x_flash_bank_command,
index d21e9fa..ce89bb4 100644 (file)
@@ -1114,7 +1114,7 @@ static const struct command_registration stm32x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stm32h7x_flash = {
+const struct flash_driver stm32h7x_flash = {
        .name = "stm32h7x",
        .commands = stm32x_command_handlers,
        .flash_bank_command = stm32x_flash_bank_command,
index 7d1e429..3d4303b 100644 (file)
@@ -1053,7 +1053,7 @@ static const struct command_registration stm32l4_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stm32l4x_flash = {
+const struct flash_driver stm32l4x_flash = {
        .name = "stm32l4x",
        .commands = stm32l4_command_handlers,
        .flash_bank_command = stm32l4_flash_bank_command,
index 814df8f..2778010 100644 (file)
@@ -944,7 +944,7 @@ static const struct command_registration stm32lx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver stm32lx_flash = {
+const struct flash_driver stm32lx_flash = {
                .name = "stm32lx",
                .commands = stm32lx_command_handlers,
                .flash_bank_command = stm32lx_flash_bank_command,
index b55c8b9..f56b9b7 100644 (file)
@@ -652,7 +652,7 @@ static int get_stmsmi_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver stmsmi_flash = {
+const struct flash_driver stmsmi_flash = {
        .name = "stmsmi",
        .flash_bank_command = stmsmi_flash_bank_command,
        .erase = stmsmi_erase,
index 015202a..eaef197 100644 (file)
@@ -799,7 +799,7 @@ static const struct command_registration str7x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver str7x_flash = {
+const struct flash_driver str7x_flash = {
        .name = "str7x",
        .commands = str7x_command_handlers,
        .flash_bank_command = str7x_flash_bank_command,
index 37700ce..85cbe6a 100644 (file)
@@ -667,7 +667,7 @@ static const struct command_registration str9x_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver str9x_flash = {
+const struct flash_driver str9x_flash = {
        .name = "str9x",
        .commands = str9x_command_handlers,
        .flash_bank_command = str9x_flash_bank_command,
index 29e0977..b618706 100644 (file)
@@ -1195,7 +1195,7 @@ static const struct command_registration str9xpec_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver str9xpec_flash = {
+const struct flash_driver str9xpec_flash = {
        .name = "str9xpec",
        .commands = str9xpec_command_handlers,
        .flash_bank_command = str9xpec_flash_bank_command,
index 93c4d28..6e216e6 100644 (file)
@@ -1107,7 +1107,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
        }
 
        const char *driver_name = CMD_ARGV[0];
-       struct flash_driver *driver = flash_driver_find_by_name(driver_name);
+       const struct flash_driver *driver = flash_driver_find_by_name(driver_name);
        if (NULL == driver) {
                /* no matching flash driver found */
                LOG_ERROR("flash driver '%s' not found", driver_name);
index 62fe2f5..195d1ae 100644 (file)
@@ -1162,7 +1162,7 @@ FLASH_BANK_COMMAND_HANDLER(tms470_flash_bank_command)
        return ERROR_OK;
 }
 
-struct flash_driver tms470_flash = {
+const struct flash_driver tms470_flash = {
        .name = "tms470",
        .commands = tms470_command_handlers,
        .flash_bank_command = tms470_flash_bank_command,
index 217f7a4..fa51537 100644 (file)
@@ -224,7 +224,7 @@ static int virtual_flash_read(struct flash_bank *bank,
        return ERROR_OK;
 }
 
-struct flash_driver virtual_flash = {
+const struct flash_driver virtual_flash = {
        .name = "virtual",
        .flash_bank_command = virtual_flash_bank_command,
        .erase = virtual_erase,
index 3d37616..3a6f3ff 100644 (file)
@@ -376,7 +376,7 @@ static int get_w600_info(struct flash_bank *bank, char *buf, int buf_size)
        return ERROR_OK;
 }
 
-struct flash_driver w600_flash = {
+const struct flash_driver w600_flash = {
        .name = "w600",
        .flash_bank_command = w600_flash_bank_command,
        .erase = w600_erase,
index bc4b1be..a0c35c5 100644 (file)
@@ -881,7 +881,7 @@ static const struct command_registration xcf_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver xcf_flash = {
+const struct flash_driver xcf_flash = {
        .name               = "xcf",
        .usage              = NULL,
        .commands           = xcf_command_handlers,
index 262300c..7589771 100644 (file)
@@ -534,7 +534,7 @@ static const struct command_registration xmc1xxx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver xmc1xxx_flash = {
+const struct flash_driver xmc1xxx_flash = {
        .name = "xmc1xxx",
        .commands = xmc1xxx_command_handlers,
        .flash_bank_command = xmc1xxx_flash_bank_command,
index d862e85..c56adb5 100644 (file)
@@ -1343,7 +1343,7 @@ static const struct command_registration xmc4xxx_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct flash_driver xmc4xxx_flash = {
+const struct flash_driver xmc4xxx_flash = {
        .name = "xmc4xxx",
        .commands = xmc4xxx_command_handlers,
        .flash_bank_command = xmc4xxx_flash_bank_command,