From a7479fa89def9d8b1854d629dfdaa0ba17132617 Mon Sep 17 00:00:00 2001 From: Christopher Head Date: Thu, 13 Dec 2018 11:53:59 -0800 Subject: Constify struct flash_driver instances 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 Reviewed-on: http://openocd.zylin.com/4803 Reviewed-by: Antonio Borneo Tested-by: jenkins Reviewed-by: Matthias Welwarsky --- src/flash/nor/aduc702x.c | 2 +- src/flash/nor/aducm360.c | 2 +- src/flash/nor/ambiqmicro.c | 2 +- src/flash/nor/at91sam3.c | 4 +- src/flash/nor/at91sam4.c | 4 +- src/flash/nor/at91sam4l.c | 2 +- src/flash/nor/at91sam7.c | 2 +- src/flash/nor/at91samd.c | 2 +- src/flash/nor/ath79.c | 2 +- src/flash/nor/atsame5.c | 2 +- src/flash/nor/atsamv.c | 4 +- src/flash/nor/avrf.c | 2 +- src/flash/nor/bluenrg-x.c | 2 +- src/flash/nor/cc26xx.c | 2 +- src/flash/nor/cc3220sf.c | 2 +- src/flash/nor/cfi.c | 2 +- src/flash/nor/core.h | 2 +- src/flash/nor/driver.h | 2 +- src/flash/nor/drivers.c | 130 ++++++++++++++++++++-------------------- src/flash/nor/dsp5680xx_flash.c | 2 +- src/flash/nor/efm32.c | 2 +- src/flash/nor/em357.c | 2 +- src/flash/nor/esirisc_flash.c | 2 +- src/flash/nor/faux.c | 2 +- src/flash/nor/fespi.c | 2 +- src/flash/nor/fm3.c | 2 +- src/flash/nor/fm4.c | 2 +- src/flash/nor/jtagspi.c | 2 +- src/flash/nor/kinetis.c | 4 +- src/flash/nor/kinetis_ke.c | 2 +- src/flash/nor/lpc2000.c | 2 +- src/flash/nor/lpc288x.c | 2 +- src/flash/nor/lpc2900.c | 2 +- src/flash/nor/lpcspifi.c | 2 +- src/flash/nor/max32xxx.c | 2 +- src/flash/nor/mdr.c | 2 +- src/flash/nor/mrvlqspi.c | 2 +- src/flash/nor/msp432.c | 2 +- src/flash/nor/niietcm4.c | 2 +- src/flash/nor/nrf5.c | 4 +- src/flash/nor/numicro.c | 2 +- src/flash/nor/ocl.c | 2 +- src/flash/nor/pic32mx.c | 2 +- src/flash/nor/psoc4.c | 2 +- src/flash/nor/psoc5lp.c | 6 +- src/flash/nor/psoc6.c | 2 +- src/flash/nor/sim3x.c | 2 +- src/flash/nor/stellaris.c | 2 +- src/flash/nor/stm32f1x.c | 2 +- src/flash/nor/stm32f2x.c | 2 +- src/flash/nor/stm32h7x.c | 2 +- src/flash/nor/stm32l4x.c | 2 +- src/flash/nor/stm32lx.c | 2 +- src/flash/nor/stmsmi.c | 2 +- src/flash/nor/str7x.c | 2 +- src/flash/nor/str9x.c | 2 +- src/flash/nor/str9xpec.c | 2 +- src/flash/nor/tcl.c | 2 +- src/flash/nor/tms470.c | 2 +- src/flash/nor/virtual.c | 2 +- src/flash/nor/w600.c | 2 +- src/flash/nor/xcf.c | 2 +- src/flash/nor/xmc1xxx.c | 2 +- src/flash/nor/xmc4xxx.c | 2 +- 64 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c index 824112b..b6e1937 100644 --- a/src/flash/nor/aduc702x.c +++ b/src/flash/nor/aduc702x.c @@ -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, diff --git a/src/flash/nor/aducm360.c b/src/flash/nor/aducm360.c index 7663783..f468c89 100644 --- a/src/flash/nor/aducm360.c +++ b/src/flash/nor/aducm360.c @@ -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, diff --git a/src/flash/nor/ambiqmicro.c b/src/flash/nor/ambiqmicro.c index 13b2b26..a536d54 100644 --- a/src/flash/nor/ambiqmicro.c +++ b/src/flash/nor/ambiqmicro.c @@ -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, diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c index 7119188..2d61a87 100644 --- a/src/flash/nor/at91sam3.c +++ b/src/flash/nor/at91sam3.c @@ -109,7 +109,7 @@ #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, diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c index d4d48a7..446f798 100644 --- a/src/flash/nor/at91sam4.c +++ b/src/flash/nor/at91sam4.c @@ -103,7 +103,7 @@ #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, diff --git a/src/flash/nor/at91sam4l.c b/src/flash/nor/at91sam4l.c index f3b065f..1c2402f 100644 --- a/src/flash/nor/at91sam4l.c +++ b/src/flash/nor/at91sam4l.c @@ -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, diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c index 9de8293..15b93a2 100644 --- a/src/flash/nor/at91sam7.c +++ b/src/flash/nor/at91sam7.c @@ -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 ", .commands = at91sam7_command_handlers, diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c index 029579b..ad0da5d 100644 --- a/src/flash/nor/at91samd.c +++ b/src/flash/nor/at91samd.c @@ -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, diff --git a/src/flash/nor/ath79.c b/src/flash/nor/ath79.c index af2112a..c551f27 100644 --- a/src/flash/nor/ath79.c +++ b/src/flash/nor/ath79.c @@ -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, diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index ff99e7d..833177e 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -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, diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c index 9c07bdf..5beeefc 100644 --- a/src/flash/nor/atsamv.c +++ b/src/flash/nor/atsamv.c @@ -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, diff --git a/src/flash/nor/avrf.c b/src/flash/nor/avrf.c index b88f6f6..6969f77 100644 --- a/src/flash/nor/avrf.c +++ b/src/flash/nor/avrf.c @@ -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, diff --git a/src/flash/nor/bluenrg-x.c b/src/flash/nor/bluenrg-x.c index f1b2062..f6a2492 100644 --- a/src/flash/nor/bluenrg-x.c +++ b/src/flash/nor/bluenrg-x.c @@ -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, diff --git a/src/flash/nor/cc26xx.c b/src/flash/nor/cc26xx.c index 0320e92..176211a 100644 --- a/src/flash/nor/cc26xx.c +++ b/src/flash/nor/cc26xx.c @@ -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, diff --git a/src/flash/nor/cc3220sf.c b/src/flash/nor/cc3220sf.c index 2441124..afdb7f4 100644 --- a/src/flash/nor/cc3220sf.c +++ b/src/flash/nor/cc3220sf.c @@ -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, diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index 1638628..04fa83b 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -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, diff --git a/src/flash/nor/core.h b/src/flash/nor/core.h index bd3aa70..f6bd0cf 100644 --- a/src/flash/nor/core.h +++ b/src/flash/nor/core.h @@ -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. */ diff --git a/src/flash/nor/driver.h b/src/flash/nor/driver.h index ef69a0f..9c56d4e 100644 --- a/src/flash/nor/driver.h +++ b/src/flash/nor/driver.h @@ -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 */ diff --git a/src/flash/nor/drivers.c b/src/flash/nor/drivers.c index 31caa5a..955d149 100644 --- a/src/flash/nor/drivers.c +++ b/src/flash/nor/drivers.c @@ -20,75 +20,75 @@ #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) diff --git a/src/flash/nor/dsp5680xx_flash.c b/src/flash/nor/dsp5680xx_flash.c index 38649ff..37b60f0 100644 --- a/src/flash/nor/dsp5680xx_flash.c +++ b/src/flash/nor/dsp5680xx_flash.c @@ -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, diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c index 8ff689c..d2ac3a8 100644 --- a/src/flash/nor/efm32.c +++ b/src/flash/nor/efm32.c @@ -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, diff --git a/src/flash/nor/em357.c b/src/flash/nor/em357.c index b14e032..e6b2728 100644 --- a/src/flash/nor/em357.c +++ b/src/flash/nor/em357.c @@ -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, diff --git a/src/flash/nor/esirisc_flash.c b/src/flash/nor/esirisc_flash.c index 9e11571..948d001 100644 --- a/src/flash/nor/esirisc_flash.c +++ b/src/flash/nor/esirisc_flash.c @@ -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", diff --git a/src/flash/nor/faux.c b/src/flash/nor/faux.c index d68940f..49b6dcc 100644 --- a/src/flash/nor/faux.c +++ b/src/flash/nor/faux.c @@ -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, diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index ea47afd..1c343a8 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -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, diff --git a/src/flash/nor/fm3.c b/src/flash/nor/fm3.c index 6c61977..f2da2af 100644 --- a/src/flash/nor/fm3.c +++ b/src/flash/nor/fm3.c @@ -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, diff --git a/src/flash/nor/fm4.c b/src/flash/nor/fm4.c index 171cbd7..a8877b4 100644 --- a/src/flash/nor/fm4.c +++ b/src/flash/nor/fm4.c @@ -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, diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c index 0750fdf..a9f2dd4 100644 --- a/src/flash/nor/jtagspi.c +++ b/src/flash/nor/jtagspi.c @@ -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, diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index d827355..22c5d5c 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -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, diff --git a/src/flash/nor/kinetis_ke.c b/src/flash/nor/kinetis_ke.c index 9441a9d..27b6d3a 100644 --- a/src/flash/nor/kinetis_ke.c +++ b/src/flash/nor/kinetis_ke.c @@ -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, diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c index 58afd79..cb3f58e 100644 --- a/src/flash/nor/lpc2000.c +++ b/src/flash/nor/lpc2000.c @@ -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, diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c index afa8d79..8852c85 100644 --- a/src/flash/nor/lpc288x.c +++ b/src/flash/nor/lpc288x.c @@ -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, diff --git a/src/flash/nor/lpc2900.c b/src/flash/nor/lpc2900.c index 022fb82..c798e44 100644 --- a/src/flash/nor/lpc2900.c +++ b/src/flash/nor/lpc2900.c @@ -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, diff --git a/src/flash/nor/lpcspifi.c b/src/flash/nor/lpcspifi.c index a7e65ec..19d754b 100644 --- a/src/flash/nor/lpcspifi.c +++ b/src/flash/nor/lpcspifi.c @@ -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, diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c index ca037de..12e3db9 100644 --- a/src/flash/nor/max32xxx.c +++ b/src/flash/nor/max32xxx.c @@ -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, diff --git a/src/flash/nor/mdr.c b/src/flash/nor/mdr.c index c4a4458..3796259 100644 --- a/src/flash/nor/mdr.c +++ b/src/flash/nor/mdr.c @@ -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 mdr 0 0 \n" ": 0 for main memory, 1 for info memory", diff --git a/src/flash/nor/mrvlqspi.c b/src/flash/nor/mrvlqspi.c index cb2cfdb..803e84a 100644 --- a/src/flash/nor/mrvlqspi.c +++ b/src/flash/nor/mrvlqspi.c @@ -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, diff --git a/src/flash/nor/msp432.c b/src/flash/nor/msp432.c index e2e65d4..e9e4be3 100644 --- a/src/flash/nor/msp432.c +++ b/src/flash/nor/msp432.c @@ -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, diff --git a/src/flash/nor/niietcm4.c b/src/flash/nor/niietcm4.c index f2f4470..b034ee1 100644 --- a/src/flash/nor/niietcm4.c +++ b/src/flash/nor/niietcm4.c @@ -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 niietcm4 0 0 ", .commands = niietcm4_command_handlers, diff --git a/src/flash/nor/nrf5.c b/src/flash/nor/nrf5.c index 1e8dda3..aab80f9 100644 --- a/src/flash/nor/nrf5.c +++ b/src/flash/nor/nrf5.c @@ -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, diff --git a/src/flash/nor/numicro.c b/src/flash/nor/numicro.c index ebf9d53..8d8abd5 100644 --- a/src/flash/nor/numicro.c +++ b/src/flash/nor/numicro.c @@ -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, diff --git a/src/flash/nor/ocl.c b/src/flash/nor/ocl.c index acc464b..d2a6594 100644 --- a/src/flash/nor/ocl.c +++ b/src/flash/nor/ocl.c @@ -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, diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 852a8bd..5ad4cb7 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -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, diff --git a/src/flash/nor/psoc4.c b/src/flash/nor/psoc4.c index 47d60de..0058f2d 100644 --- a/src/flash/nor/psoc4.c +++ b/src/flash/nor/psoc4.c @@ -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, diff --git a/src/flash/nor/psoc5lp.c b/src/flash/nor/psoc5lp.c index 47567e7..66e2b07 100644 --- a/src/flash/nor/psoc5lp.c +++ b/src/flash/nor/psoc5lp.c @@ -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, diff --git a/src/flash/nor/psoc6.c b/src/flash/nor/psoc6.c index 9352ad4..386075e 100644 --- a/src/flash/nor/psoc6.c +++ b/src/flash/nor/psoc6.c @@ -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, diff --git a/src/flash/nor/sim3x.c b/src/flash/nor/sim3x.c index f282ba0..7ccf56b 100644 --- a/src/flash/nor/sim3x.c +++ b/src/flash/nor/sim3x.c @@ -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, diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c index 8731f8b..6b6f6e8 100644 --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -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, diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c index cd060da..d5d59c6 100644 --- a/src/flash/nor/stm32f1x.c +++ b/src/flash/nor/stm32f1x.c @@ -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, diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c index 63c8347..23f0030 100644 --- a/src/flash/nor/stm32f2x.c +++ b/src/flash/nor/stm32f2x.c @@ -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, diff --git a/src/flash/nor/stm32h7x.c b/src/flash/nor/stm32h7x.c index d21e9fa..ce89bb4 100644 --- a/src/flash/nor/stm32h7x.c +++ b/src/flash/nor/stm32h7x.c @@ -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, diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 7d1e429..3d4303b 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -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, diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index 814df8f..2778010 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -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, diff --git a/src/flash/nor/stmsmi.c b/src/flash/nor/stmsmi.c index b55c8b9..f56b9b7 100644 --- a/src/flash/nor/stmsmi.c +++ b/src/flash/nor/stmsmi.c @@ -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, diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index 015202a..eaef197 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -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, diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c index 37700ce..85cbe6a 100644 --- a/src/flash/nor/str9x.c +++ b/src/flash/nor/str9x.c @@ -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, diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c index 29e0977..b618706 100644 --- a/src/flash/nor/str9xpec.c +++ b/src/flash/nor/str9xpec.c @@ -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, diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 93c4d28..6e216e6 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -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); diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c index 62fe2f5..195d1ae 100644 --- a/src/flash/nor/tms470.c +++ b/src/flash/nor/tms470.c @@ -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, diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c index 217f7a4..fa51537 100644 --- a/src/flash/nor/virtual.c +++ b/src/flash/nor/virtual.c @@ -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, diff --git a/src/flash/nor/w600.c b/src/flash/nor/w600.c index 3d37616..3a6f3ff 100644 --- a/src/flash/nor/w600.c +++ b/src/flash/nor/w600.c @@ -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, diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c index bc4b1be..a0c35c5 100644 --- a/src/flash/nor/xcf.c +++ b/src/flash/nor/xcf.c @@ -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, diff --git a/src/flash/nor/xmc1xxx.c b/src/flash/nor/xmc1xxx.c index 262300c..7589771 100644 --- a/src/flash/nor/xmc1xxx.c +++ b/src/flash/nor/xmc1xxx.c @@ -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, diff --git a/src/flash/nor/xmc4xxx.c b/src/flash/nor/xmc4xxx.c index d862e85..c56adb5 100644 --- a/src/flash/nor/xmc4xxx.c +++ b/src/flash/nor/xmc4xxx.c @@ -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, -- cgit v1.1