From fc37cdb2dd51ad79cf59e63139778f77af2a07b2 Mon Sep 17 00:00:00 2001 From: oharboe Date: Thu, 28 Feb 2008 11:00:35 +0000 Subject: [PATCH] Pavel Chromy - cleanup error messages git-svn-id: svn://svn.berlios.de/openocd/trunk@376 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/flash/flash.c | 51 +++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/src/flash/flash.c b/src/flash/flash.c index 84d11586..96a74cd6 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -88,63 +88,40 @@ static int auto_erase = 0; /* wafer thin wrapper for invoking the flash driver */ static int flash_driver_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count) { - int retval=ERROR_OK; - if (bank->target->state != TARGET_HALTED) - { - ERROR("target not halted - aborting flash write"); - retval=ERROR_TARGET_NOT_HALTED; - } else - { - retval=bank->driver->write(bank, buffer, offset, count); - } + int retval; + + retval=bank->driver->write(bank, buffer, offset, count); if (retval!=ERROR_OK) { - ERROR("Writing to flash bank at address 0x%08x at offset 0x%8.8x", bank->base, offset); + ERROR("error writing to flash at address 0x%08x at offset 0x%8.8x", bank->base, offset); } + return retval; } static int flash_driver_erase(struct flash_bank_s *bank, int first, int last) { - int retval=ERROR_OK; - if (bank->target->state != TARGET_HALTED) - { - ERROR("target not halted - aborting flash erase"); - retval=ERROR_TARGET_NOT_HALTED; - } else if ((first < 0) || (last < first) || (last >= bank->num_sectors)) - { - ERROR("invalid flash sector"); - retval=ERROR_FLASH_SECTOR_INVALID; - } else - { - retval=bank->driver->erase(bank, first, last); - } + int retval; + + retval=bank->driver->erase(bank, first, last); if (retval!=ERROR_OK) { - ERROR("Failed erasing banks %d to %d", first, last); + ERROR("failed erasing banks %d to %d", first, last); } + return retval; } int flash_driver_protect(struct flash_bank_s *bank, int set, int first, int last) { int retval; - if (bank->target->state != TARGET_HALTED) - { - ERROR("target not halted - aborting flash erase"); - retval=ERROR_TARGET_NOT_HALTED; - } else if ((first < 0) || (last < first) || (last >= bank->num_sectors)) - { - ERROR("invalid flash sector"); - retval=ERROR_FLASH_SECTOR_INVALID; - } else - { - retval=bank->driver->protect(bank, set, first, last); - } + + retval=bank->driver->protect(bank, set, first, last); if (retval!=ERROR_OK) { - ERROR("Failed protecting banks %d to %d", first, last); + ERROR("failed protecting banks %d to %d", first, last); } + return retval; } -- 2.39.5