flash/nor: use default_flash_blank_check() instead of dummy 66/4766/2
authorTomas Vanek <vanekt@fbl.cz>
Thu, 15 Nov 2018 13:50:08 +0000 (14:50 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Wed, 5 Dec 2018 07:55:53 +0000 (07:55 +0000)
Some flash drivers had a dummy method for erase_check.
Use default_flash_blank_check() instead if possible.

Change-Id: Iddfeff45ce477007328d061fcb5c553d93c3be98
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4766
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
src/flash/nor/at91sam3.c
src/flash/nor/lpc288x.c
src/flash/nor/ocl.c

index d80b6fe..7119188 100644 (file)
@@ -2991,28 +2991,6 @@ static int sam3_GetInfo(struct sam3_chip *pChip)
        return ERROR_OK;
 }
 
-static int sam3_erase_check(struct flash_bank *bank)
-{
-       int x;
-
-       LOG_DEBUG("Here");
-       if (bank->target->state != TARGET_HALTED) {
-               LOG_ERROR("Target not halted");
-               return ERROR_TARGET_NOT_HALTED;
-       }
-       if (0 == bank->num_sectors) {
-               LOG_ERROR("Target: not supported/not probed");
-               return ERROR_FAIL;
-       }
-
-       LOG_INFO("sam3 - supports auto-erase, erase_check ignored");
-       for (x = 0; x < bank->num_sectors; x++)
-               bank->sectors[x].is_erased = 1;
-
-       LOG_DEBUG("Done");
-       return ERROR_OK;
-}
-
 static int sam3_protect_check(struct flash_bank *bank)
 {
        int r;
@@ -3785,7 +3763,7 @@ struct flash_driver at91sam3_flash = {
        .read = default_flash_read,
        .probe = sam3_probe,
        .auto_probe = sam3_auto_probe,
-       .erase_check = sam3_erase_check,
+       .erase_check = default_flash_blank_check,
        .protect_check = sam3_protect_check,
        .free_driver_priv = sam3_free_driver_priv,
 };
index 474e721..afa8d79 100644 (file)
@@ -232,17 +232,6 @@ static uint32_t lpc288x_system_ready(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int lpc288x_erase_check(struct flash_bank *bank)
-{
-       uint32_t status = lpc288x_system_ready(bank);   /* probed? halted? */
-       if (status != ERROR_OK) {
-               LOG_INFO("Processor not halted/not probed");
-               return status;
-       }
-
-       return ERROR_OK;
-}
-
 static int lpc288x_erase(struct flash_bank *bank, int first, int last)
 {
        uint32_t status;
@@ -432,7 +421,7 @@ struct flash_driver lpc288x_flash = {
        .read = default_flash_read,
        .probe = lpc288x_probe,
        .auto_probe = lpc288x_probe,
-       .erase_check = lpc288x_erase_check,
+       .erase_check = default_flash_blank_check,
        .protect_check = lpc288x_protect_check,
        .free_driver_priv = default_flash_free_driver_priv,
 };
index f8913c0..acc464b 100644 (file)
@@ -30,11 +30,6 @@ struct ocl_priv {
        unsigned int bufalign;
 };
 
-static int ocl_erase_check(struct flash_bank *bank)
-{
-       return ERROR_OK;
-}
-
 /* flash_bank ocl 0 0 0 0 <target#> */
 FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command)
 {
@@ -326,7 +321,7 @@ struct flash_driver ocl_flash = {
        .write = ocl_write,
        .read = default_flash_read,
        .probe = ocl_probe,
-       .erase_check = ocl_erase_check,
+       .erase_check = default_flash_blank_check,
        .auto_probe = ocl_auto_probe,
        .free_driver_priv = default_flash_free_driver_priv,
 };