]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd_sf: Add print mesgs on sf read/write commands
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sun, 26 May 2013 09:22:52 +0000 (14:52 +0530)
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sun, 2 Jun 2013 18:34:41 +0000 (00:04 +0530)
This patch adds a print messages while using 'sf read' and
'sf write' commands to make sure that how many bytes read/written
from/into 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 7f12a494847cf2abae63df8371ef5a97aa5531e2..19b0dc9f433c9cc5dc7357aadda3d3c00dc87f9b 100644 (file)
@@ -234,7 +234,7 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
        unsigned long len;
        void *buf;
        char *endp;
-       int ret;
+       int ret = 1;
 
        if (argc < 4)
                return -1;
@@ -264,19 +264,23 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
 
        if (strcmp(argv[0], "update") == 0)
                ret = spi_flash_update(flash, offset, len, buf);
-       else if (strcmp(argv[0], "read") == 0)
-               ret = spi_flash_read(flash, offset, len, buf);
-       else
-               ret = spi_flash_write(flash, offset, len, buf);
+       else if (strncmp(argv[0], "read", 4) == 0 ||
+                       strncmp(argv[0], "write", 5) == 0) {
+               int read;
+
+               read = strncmp(argv[0], "read", 4) == 0;
+               if (read)
+                       ret = spi_flash_read(flash, offset, len, buf);
+               else
+                       ret = spi_flash_write(flash, offset, len, buf);
+
+               printf("SF: %zu bytes @ %#x %s: %s\n", (size_t)len, (u32)offset,
+                       read ? "Read" : "Written", ret ? "ERROR" : "OK");
+       }
 
        unmap_physmem(buf, len);
 
-       if (ret) {
-               printf("SPI flash %s failed\n", argv[0]);
-               return 1;
-       }
-
-       return 0;
+       return ret == 0 ? 0 : 1;
 }
 
 static int do_spi_flash_erase(int argc, char * const argv[])
index de6fd58e8c30831fb1439222e42b0bb2e1c7f872..0e38f594819073f91ee6bcaa3215c64fd46233ff 100644 (file)
@@ -124,9 +124,6 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
                }
        }
 
-       debug("SF: program %s %zu bytes @ %#x\n",
-             ret ? "failure" : "success", len, offset);
-
        spi_release_bus(flash->spi);
        return ret;
 }