cmd_sf: Add print mesg for 'sf erase' command
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sat, 25 May 2013 20:05:21 +0000 (01:35 +0530)
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sun, 2 Jun 2013 18:34:40 +0000 (00:04 +0530)
This patch adds a print messages while using 'sf erase' command
to make sure that how many bytes erased in flash device.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Acked-by: Tom Rini <trini@ti.com>
common/cmd_sf.c
drivers/mtd/spi/spi_flash.c

index 0a17782d662c1f950029935970bf661b56387b23..7f12a494847cf2abae63df8371ef5a97aa5531e2 100644 (file)
@@ -305,12 +305,10 @@ static int do_spi_flash_erase(int argc, char * const argv[])
        }
 
        ret = spi_flash_erase(flash, offset, len);
-       if (ret) {
-               printf("SPI flash %s failed\n", argv[0]);
-               return 1;
-       }
+       printf("SF: %zu bytes @ %#x Erased: %s\n", (size_t)len, (u32)offset,
+                       ret ? "ERROR" : "OK");
 
-       return 0;
+       return ret == 0 ? 0 : 1;
 }
 
 #ifdef CONFIG_CMD_SF_TEST
index 6fa932cbd9c3de70300a136e13136932e7ad49c1..de6fd58e8c30831fb1439222e42b0bb2e1c7f872 100644 (file)
@@ -207,7 +207,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
 
 int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
 {
-       u32 start, end, erase_size;
+       u32 end, erase_size;
        int ret;
        u8 cmd[4];
 
@@ -227,8 +227,7 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
                cmd[0] = CMD_ERASE_4K;
        else
                cmd[0] = CMD_ERASE_64K;
-       start = offset;
-       end = start + len;
+       end = offset + len;
 
        while (offset < end) {
                spi_flash_addr(offset, cmd);
@@ -250,8 +249,6 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
                        goto out;
        }
 
-       debug("SF: Successfully erased %zu bytes @ %#x\n", len, start);
-
  out:
        spi_release_bus(flash->spi);
        return ret;