aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2013-09-21 18:39:01 +0200
committerSpencer Oliver <spen@spen-soft.co.uk>2013-10-03 09:22:34 +0000
commitcbf4760e15d217c0a83e65f13bddfcbfad7d2fec (patch)
tree2d943cc64ff9ed8e6c4236316c32690ddb949a61 /src
parentc8492ee2d468bcee8e2b7bb0560e6329c12a86e2 (diff)
flash/nor: Make info function optional
Remove lots of no-op or dummy info function implementations and check if it's implemented before invoking it. Change-Id: I2144dad6a84a80359bb13a8a29a4614387e4c135 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/1642 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/flash/nor/aduc702x.c7
-rw-r--r--src/flash/nor/at91sam3.c11
-rw-r--r--src/flash/nor/at91sam4.c11
-rw-r--r--src/flash/nor/dsp5680xx_flash.c9
-rw-r--r--src/flash/nor/em357.c8
-rw-r--r--src/flash/nor/fm3.c7
-rw-r--r--src/flash/nor/lpc288x.c7
-rw-r--r--src/flash/nor/lpc2900.c14
-rw-r--r--src/flash/nor/mini51.c7
-rw-r--r--src/flash/nor/ocl.c6
-rw-r--r--src/flash/nor/str7x.c3
-rw-r--r--src/flash/nor/str9x.c7
-rw-r--r--src/flash/nor/str9xpec.c7
-rw-r--r--src/flash/nor/tcl.c13
14 files changed, 8 insertions, 109 deletions
diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c
index 432bd802..a0610d43 100644
--- a/src/flash/nor/aduc702x.c
+++ b/src/flash/nor/aduc702x.c
@@ -352,12 +352,6 @@ static int aduc702x_probe(struct flash_bank *bank)
return ERROR_OK;
}
-static int aduc702x_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "aduc702x flash driver info");
- return ERROR_OK;
-}
-
/* sets FEEMOD bit 3
* enable = 1 enables writes & erases, 0 disables them */
static int aduc702x_set_write_enable(struct target *target, int enable)
@@ -407,5 +401,4 @@ struct flash_driver aduc702x_flash = {
.auto_probe = aduc702x_probe,
.erase_check = default_flash_blank_check,
.protect_check = aduc702x_protect_check,
- .info = aduc702x_info
};
diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index 1bb549e3..6fe71bfb 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3179,16 +3179,6 @@ static int sam3_protect(struct flash_bank *bank, int set, int first, int last)
}
-static int sam3_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- if (bank->target->state != TARGET_HALTED) {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
- buf[0] = 0;
- return ERROR_OK;
-}
-
static int sam3_page_read(struct sam3_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
{
uint32_t adr;
@@ -3733,5 +3723,4 @@ struct flash_driver at91sam3_flash = {
.auto_probe = sam3_auto_probe,
.erase_check = sam3_erase_check,
.protect_check = sam3_protect_check,
- .info = sam3_info,
};
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index 1ba39109..c7385c4f 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -1819,16 +1819,6 @@ static int sam4_protect(struct flash_bank *bank, int set, int first, int last)
}
-static int sam4_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- if (bank->target->state != TARGET_HALTED) {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
- buf[0] = 0;
- return ERROR_OK;
-}
-
static int sam4_page_read(struct sam4_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
{
uint32_t adr;
@@ -2376,5 +2366,4 @@ struct flash_driver at91sam4_flash = {
.auto_probe = sam4_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = sam4_protect_check,
- .info = sam4_info,
};
diff --git a/src/flash/nor/dsp5680xx_flash.c b/src/flash/nor/dsp5680xx_flash.c
index b935a1e8..9368d892 100644
--- a/src/flash/nor/dsp5680xx_flash.c
+++ b/src/flash/nor/dsp5680xx_flash.c
@@ -193,14 +193,6 @@ static int dsp5680xx_probe(struct flash_bank *bank)
return ERROR_OK;
}
-static int dsp5680xx_flash_info(struct flash_bank *bank, char *buf,
- int buf_size)
-{
- snprintf(buf, buf_size,
- "\ndsp5680xx flash driver info:\n - See comments in code.");
- return ERROR_OK;
-}
-
/**
* The flash module (FM) on the dsp5680xx supports both individual sector
* and mass erase of the flash memory.
@@ -277,5 +269,4 @@ struct flash_driver dsp5680xx_flash = {
.auto_probe = dsp5680xx_probe,
.erase_check = dsp5680xx_flash_erase_check,
.protect_check = dsp5680xx_flash_protect_check,
- .info = dsp5680xx_flash_info
};
diff --git a/src/flash/nor/em357.c b/src/flash/nor/em357.c
index 49aee7e8..8f25a89b 100644
--- a/src/flash/nor/em357.c
+++ b/src/flash/nor/em357.c
@@ -751,13 +751,6 @@ static int em357_auto_probe(struct flash_bank *bank)
return em357_probe(bank);
}
-
-static int get_em357_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "em357\n");
- return ERROR_OK;
-}
-
COMMAND_HANDLER(em357_handle_lock_command)
{
struct target *target = NULL;
@@ -946,5 +939,4 @@ struct flash_driver em357_flash = {
.auto_probe = em357_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = em357_protect_check,
- .info = get_em357_info,
};
diff --git a/src/flash/nor/fm3.c b/src/flash/nor/fm3.c
index a9a11a31..86e4cb24 100644
--- a/src/flash/nor/fm3.c
+++ b/src/flash/nor/fm3.c
@@ -760,12 +760,6 @@ static int fm3_auto_probe(struct flash_bank *bank)
return fm3_probe(bank);
}
-static int fm3_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "Fujitsu fm3 Device does not support Chip-ID (Type unknown)");
- return ERROR_OK;
-}
-
/* Chip erase */
static int fm3_chip_erase(struct flash_bank *bank)
{
@@ -907,5 +901,4 @@ struct flash_driver fm3_flash = {
.probe = fm3_probe,
.auto_probe = fm3_auto_probe,
.erase_check = default_flash_blank_check,
- .info = fm3_info,
};
diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c
index 7428d794..57107658 100644
--- a/src/flash/nor/lpc288x.c
+++ b/src/flash/nor/lpc288x.c
@@ -400,12 +400,6 @@ static int lpc288x_probe(struct flash_bank *bank)
return ERROR_OK;
}
-static int lpc288x_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "lpc288x flash driver");
- return ERROR_OK;
-}
-
static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last)
{
int lockregion, status;
@@ -450,5 +444,4 @@ struct flash_driver lpc288x_flash = {
.auto_probe = lpc288x_probe,
.erase_check = lpc288x_erase_check,
.protect_check = lpc288x_protect_check,
- .info = lpc288x_info,
};
diff --git a/src/flash/nor/lpc2900.c b/src/flash/nor/lpc2900.c
index 7fea9414..9663e51a 100644
--- a/src/flash/nor/lpc2900.c
+++ b/src/flash/nor/lpc2900.c
@@ -1588,19 +1588,6 @@ static int lpc2900_protect_check(struct flash_bank *bank)
return lpc2900_read_security_status(bank);
}
-/**
- * Print info about the driver (not the device).
- *
- * @param bank Pointer to the flash bank descriptor
- * @param buf Buffer to take the string
- * @param buf_size Maximum number of characters that the buffer can take
- */
-static int lpc2900_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "lpc2900 flash driver");
- return ERROR_OK;
-}
-
struct flash_driver lpc2900_flash = {
.name = "lpc2900",
.commands = lpc2900_command_handlers,
@@ -1613,5 +1600,4 @@ struct flash_driver lpc2900_flash = {
.auto_probe = lpc2900_probe,
.erase_check = lpc2900_erase_check,
.protect_check = lpc2900_protect_check,
- .info = lpc2900_info
};
diff --git a/src/flash/nor/mini51.c b/src/flash/nor/mini51.c
index 46e4188d..5504b5c9 100644
--- a/src/flash/nor/mini51.c
+++ b/src/flash/nor/mini51.c
@@ -395,12 +395,6 @@ static int mini51_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offse
return ERROR_OK;
}
-static int get_mini51_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "Mini51 flash driver");
- return ERROR_OK;
-}
-
static int mini51_probe(struct flash_bank *bank)
{
uint32_t flash_size;
@@ -454,5 +448,4 @@ struct flash_driver mini51_flash = {
.auto_probe = mini51_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = mini51_protect_check,
- .info = get_mini51_info,
};
diff --git a/src/flash/nor/ocl.c b/src/flash/nor/ocl.c
index 4e7198a7..6b297b0d 100644
--- a/src/flash/nor/ocl.c
+++ b/src/flash/nor/ocl.c
@@ -321,11 +321,6 @@ static int ocl_probe(struct flash_bank *bank)
return ERROR_OK;
}
-static int ocl_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- return ERROR_OK;
-}
-
static int ocl_auto_probe(struct flash_bank *bank)
{
struct ocl_priv *ocl = bank->driver_priv;
@@ -346,6 +341,5 @@ struct flash_driver ocl_flash = {
.probe = ocl_probe,
.erase_check = ocl_erase_check,
.protect_check = ocl_protect_check,
- .info = ocl_info,
.auto_probe = ocl_auto_probe,
};
diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index 49aaa3d7..93b0f837 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -707,12 +707,11 @@ COMMAND_HANDLER(str7x_handle_part_id_command)
static int get_str7x_info(struct flash_bank *bank, char *buf, int buf_size)
{
- snprintf(buf, buf_size, "str7x flash driver info");
/* STR7x flash doesn't support sector protection interrogation.
* FLASH_NVWPAR acts as a write only register; its read value
* doesn't reflect the actual protection state of the sectors.
*/
- LOG_WARNING("STR7x flash lock information might not be correct "
+ snprintf(buf, buf_size, "STR7x flash lock information might not be correct "
"due to hardware limitations.");
return ERROR_OK;
}
diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c
index be8c00b6..7d93b187 100644
--- a/src/flash/nor/str9x.c
+++ b/src/flash/nor/str9x.c
@@ -606,12 +606,6 @@ COMMAND_HANDLER(str9x_handle_part_id_command)
}
#endif
-static int get_str9x_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "str9x flash driver info");
- return ERROR_OK;
-}
-
COMMAND_HANDLER(str9x_handle_flash_config_command)
{
struct target *target = NULL;
@@ -686,5 +680,4 @@ struct flash_driver str9x_flash = {
.auto_probe = str9x_probe,
.erase_check = default_flash_blank_check,
.protect_check = str9x_protect_check,
- .info = get_str9x_info,
};
diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c
index da6c83e2..e08495da 100644
--- a/src/flash/nor/str9xpec.c
+++ b/src/flash/nor/str9xpec.c
@@ -760,12 +760,6 @@ static int str9xpec_erase_check(struct flash_bank *bank)
return str9xpec_blank_check(bank, 0, bank->num_sectors - 1);
}
-static int get_str9xpec_info(struct flash_bank *bank, char *buf, int buf_size)
-{
- snprintf(buf, buf_size, "str9xpec flash driver info");
- return ERROR_OK;
-}
-
COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
{
uint8_t status;
@@ -1215,5 +1209,4 @@ struct flash_driver str9xpec_flash = {
.auto_probe = str9xpec_probe,
.erase_check = str9xpec_erase_check,
.protect_check = str9xpec_protect_check,
- .info = get_str9xpec_info,
};
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 57c3be50..788d050b 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -101,12 +101,13 @@ COMMAND_HANDLER(handle_flash_info_command)
protect_state);
}
- *buf = '\0'; /* initialize buffer, otherwise it migh contain garbage if driver
- *function fails */
- retval = p->driver->info(p, buf, sizeof(buf));
- command_print(CMD_CTX, "%s", buf);
- if (retval != ERROR_OK)
- LOG_ERROR("error retrieving flash info");
+ if (p->driver->info != NULL) {
+ retval = p->driver->info(p, buf, sizeof(buf));
+ if (retval == ERROR_OK)
+ command_print(CMD_CTX, "%s", buf);
+ else
+ LOG_ERROR("error retrieving flash info");
+ }
}
return retval;