flash: fix error handling
authorØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 20 Sep 2010 07:22:46 +0000 (09:22 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 21 Sep 2010 20:17:38 +0000 (22:17 +0200)
sensible error must be reported at failure site

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/flash/nand/tcl.c
src/flash/nor/tcl.c

index 7b84888..57bbe00 100644 (file)
@@ -150,16 +150,8 @@ COMMAND_HANDLER(handle_nand_probe_command)
                command_print(CMD_CTX, "NAND flash device '%s (%s)' found",
                                p->device->name, p->manufacturer->name);
        }
-       else if (retval == ERROR_NAND_OPERATION_FAILED)
-       {
-               command_print(CMD_CTX, "probing failed for NAND flash device");
-       }
-       else
-       {
-               command_print(CMD_CTX, "unknown error when probing NAND flash device");
-       }
 
-       return ERROR_OK;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_nand_erase_command)
@@ -206,16 +198,8 @@ COMMAND_HANDLER(handle_nand_erase_command)
                                offset, offset + length,
                                CMD_ARGV[0], p->device->name);
        }
-       else if (retval == ERROR_NAND_OPERATION_FAILED)
-       {
-               command_print(CMD_CTX, "erase failed");
-       }
-       else
-       {
-               command_print(CMD_CTX, "unknown error when erasing NAND flash device");
-       }
 
-       return ERROR_OK;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
@@ -261,18 +245,8 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
                command_print(CMD_CTX, "checked NAND flash device for bad blocks, "
                                "use \"nand info\" command to list blocks");
        }
-       else if (retval == ERROR_NAND_OPERATION_FAILED)
-       {
-               command_print(CMD_CTX, "error when checking for bad blocks on "
-                               "NAND flash device");
-       }
-       else
-       {
-               command_print(CMD_CTX, "unknown error when checking for bad "
-                               "blocks on NAND flash device");
-       }
 
-       return ERROR_OK;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_nand_write_command)
index 3dc6cff..8604b4b 100644 (file)
@@ -132,23 +132,14 @@ COMMAND_HANDLER(handle_flash_probe_command)
                {
                        command_print(CMD_CTX, "flash '%s' found at 0x%8.8" PRIx32, p->driver->name, p->base);
                }
-               else if (retval == ERROR_FLASH_BANK_INVALID)
-               {
-                       command_print(CMD_CTX, "probing failed for flash bank '#%s' at 0x%8.8" PRIx32,
-                                                 CMD_ARGV[0], p->base);
-               }
-               else
-               {
-                       command_print(CMD_CTX, "unknown error when probing flash bank '#%s' at 0x%8.8" PRIx32,
-                                                 CMD_ARGV[0], p->base);
-               }
        }
        else
        {
                command_print(CMD_CTX, "flash bank '#%s' is out of bounds", CMD_ARGV[0]);
+               retval = ERROR_FAIL;
        }
 
-       return ERROR_OK;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_flash_erase_check_command)