From 737c9b6258c6e68714ae264ff36126eb5d382d6a Mon Sep 17 00:00:00 2001 From: Øyvind Harboe Date: Wed, 5 May 2010 15:08:34 +0200 Subject: flash: stop caching protection state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a million reasons why cached protection state might be stale: power cycling of target, reset, code executing on the target, etc. The "flash protect_check" command is now gone. This is *always* executed when running a "flash info". As a bonus for more a more robust approach, lots of code could be deleted. Signed-off-by: Øyvind Harboe --- src/flash/nor/tcl.c | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) (limited to 'src/flash/nor/tcl.c') diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 947fd046..17c6e910 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -70,6 +70,11 @@ COMMAND_HANDLER(handle_flash_info_command) if ((retval = p->driver->auto_probe(p)) != ERROR_OK) return retval; + /* We must query the hardware to avoid printing stale information! */ + retval = p->driver->protect_check(p); + if (retval != ERROR_OK) + return retval; + command_print(CMD_CTX, "#%" PRIi32 " : %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32 ", buswidth %i, chipwidth %i", i, @@ -266,32 +271,6 @@ COMMAND_HANDLER(handle_flash_erase_address_command) return retval; } -COMMAND_HANDLER(handle_flash_protect_check_command) -{ - if (CMD_ARGC != 1) - return ERROR_COMMAND_SYNTAX_ERROR; - - struct flash_bank *p; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p); - if (ERROR_OK != retval) - return retval; - - if ((retval = p->driver->protect_check(p)) == ERROR_OK) - { - command_print(CMD_CTX, "successfully checked protect state"); - } - else if (retval == ERROR_FLASH_OPERATION_FAILED) - { - command_print(CMD_CTX, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); - } - else - { - command_print(CMD_CTX, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); - } - - return ERROR_OK; -} - static int flash_check_sector_parameters(struct command_context *cmd_ctx, uint32_t first, uint32_t last, uint32_t num_sectors) { @@ -706,14 +685,6 @@ static const struct command_registration flash_exec_command_handlers[] = { .help = "Check erase state of all blocks in a " "flash bank.", }, - { - .name = "protect_check", - .handler = handle_flash_protect_check_command, - .mode = COMMAND_EXEC, - .usage = "bank_id", - .help = "Check protection state of all blocks in a " - "flash bank.", - }, { .name = "erase_sector", .handler = handle_flash_erase_command, -- cgit v1.2.3