diff mbox

[U-Boot,U-Boot,v2,2/6] cmd_sf: Add print messages on flash read/write commands

Message ID 1355934463-24319-2-git-send-email-jagannadh.teki@gmail.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagan Teki Dec. 19, 2012, 4:27 p.m. UTC
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 <jagannadh.teki@gmail.com>
---
Changes in v2:
        Move print messages from spi_flash.c into cmd_sf.c

 common/cmd_sf.c             |   26 ++++++++++++++++----------
 drivers/mtd/spi/spi_flash.c |    3 ---
 2 files changed, 16 insertions(+), 13 deletions(-)

Comments

Wolfgang Denk Dec. 19, 2012, 11:18 p.m. UTC | #1
Dear Jagannadha Sutradharudu Teki,

In message <1355934463-24319-2-git-send-email-jagannadh.teki@gmail.com> you wrote:
> 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 <jagannadh.teki@gmail.com>
> ---
> Changes in v2:
>         Move print messages from spi_flash.c into cmd_sf.c

Please see previous comments, especially

http://article.gmane.org/gmane.comp.boot-loaders.u-boot/149663
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/149665

I object against adding more and more verbosity and code size, and in
an inconsistent way.

Best regards,

Wolfgang Denk
Jagan Teki Dec. 20, 2012, 7:49 a.m. UTC | #2
Hi Wolfgang Denk,

On Thu, Dec 20, 2012 at 4:48 AM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Jagannadha Sutradharudu Teki,
>
> In message <1355934463-24319-2-git-send-email-jagannadh.teki@gmail.com> you wrote:
>> 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 <jagannadh.teki@gmail.com>
>> ---
>> Changes in v2:
>>         Move print messages from spi_flash.c into cmd_sf.c
>
> Please see previous comments, especially
>
> http://article.gmane.org/gmane.comp.boot-loaders.u-boot/149663
> http://article.gmane.org/gmane.comp.boot-loaders.u-boot/149665
>
> I object against adding more and more verbosity and code size, and in
> an inconsistent way.

Please see my comments on previous patch.
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/149698

Thanks,
Jagan.

>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
> F u cn rd ths u cnt spl wrth a dm!
diff mbox

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index ddb1a65..efdd640 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -196,7 +196,7 @@  static int do_spi_flash_read_write(int argc, char * const argv[])
 	unsigned long len;
 	void *buf;
 	char *endp;
-	int ret;
+	int ret = 0;
 
 	if (argc < 4)
 		return -1;
@@ -226,19 +226,25 @@  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;
 
-	unmap_physmem(buf, len);
+		read = strncmp(argv[0], "read", 4) == 0;
+		printf("SF: %s flash... ", read ? "Reading" : "Writing");
 
-	if (ret) {
-		printf("SPI flash %s failed\n", argv[0]);
-		return 1;
+		if (read)
+			ret = spi_flash_read(flash, offset, len, buf);
+		else
+			ret = spi_flash_write(flash, offset, len, buf);
+
+		printf("%zu bytes @ %#x %s: %s\n", (size_t)len, (u32)offset,
+			read ? "read" : "written", ret ? "ERROR" : "OK");
 	}
 
-	return 0;
+	unmap_physmem(buf, len);
+
+	return ret == 0 ? 0 : 1;
 }
 
 static int do_spi_flash_erase(int argc, char * const argv[])
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 43e0334..9e8939c 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -115,9 +115,6 @@  int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
 		byte_addr = 0;
 	}
 
-	debug("SF: program %s %zu bytes @ %#x\n",
-	      ret ? "failure" : "success", len, offset);
-
 	spi_release_bus(flash->spi);
 	return ret;
 }