All of lore.kernel.org
 help / color / mirror / Atom feed
From: Piotr Ziecik <kosmo@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] flash: Add interface for flash verbosity control
Date: Mon, 17 Nov 2008 15:49:32 +0100	[thread overview]
Message-ID: <1226933372-21393-1-git-send-email-kosmo@semihalf.com> (raw)

Add interface for flash verbosity control. It allows
to disable output from low-level flash API. It is useful
when calling these low-level functions from context other
than flash commands (for example the MTD/CFI interface
implmentation).

Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
---
 drivers/mtd/cfi_flash.c |   33 ++++++++++++++++++++++-----------
 include/flash.h         |    1 +
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 4202af4..d828e77 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -158,6 +158,7 @@ typedef union {
 #define NUM_ERASE_REGIONS	4 /* max. number of erase regions */
 
 static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT };
+static uint flash_verbose = 1;
 
 /* use CONFIG_SYS_MAX_FLASH_BANKS_DETECT if defined */
 #ifdef CONFIG_SYS_MAX_FLASH_BANKS_DETECT
@@ -1051,7 +1052,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 	if (prot) {
 		printf ("- Warning: %d protected sectors will not be erased!\n",
 			prot);
-	} else {
+	} else if (flash_verbose) {
 		putc ('\n');
 	}
 
@@ -1098,11 +1099,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 			if (flash_full_status_check
 			    (info, sect, info->erase_blk_tout, "erase")) {
 				rcode = 1;
-			} else
+			} else if (flash_verbose)
 				putc ('.');
 		}
 	}
-	puts (" done\n");
+
+	if (flash_verbose)
+		puts (" done\n");
+
 	return rcode;
 }
 
@@ -1214,14 +1218,16 @@ void flash_print_info (flash_info_t * info)
  */
 #ifdef CONFIG_FLASH_SHOW_PROGRESS
 #define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
-	dots -= dots_sub; \
-	if ((scale > 0) && (dots <= 0)) { \
-		if ((digit % 5) == 0) \
-			printf ("%d", digit / 5); \
-		else \
-			putc ('.'); \
-		digit--; \
-		dots += scale; \
+	if (flash_verbose) { \
+		dots -= dots_sub; \
+		if ((scale > 0) && (dots <= 0)) { \
+			if ((digit % 5) == 0) \
+				printf ("%d", digit / 5); \
+			else \
+				putc ('.'); \
+			digit--; \
+			dots += scale; \
+		} \
 	}
 #else
 #define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub)
@@ -1939,6 +1945,11 @@ ulong flash_get_size (ulong base, int banknum)
 	return (info->size);
 }
 
+void flash_set_verbose(uint v)
+{
+	flash_verbose = v;
+}
+
 /*-----------------------------------------------------------------------
  */
 unsigned long flash_init (void)
diff --git a/include/flash.h b/include/flash.h
index 8a00c2f..05fa572 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -95,6 +95,7 @@ extern int flash_sect_erase (ulong addr_first, ulong addr_last);
 extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
 extern int flash_sect_roundb (ulong *addr);
 extern unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect);
+extern void flash_set_verbose(uint);
 
 /* common/flash.c */
 extern void flash_protect (int flag, ulong from, ulong to, flash_info_t *info);
-- 
1.5.6.1

             reply	other threads:[~2008-11-17 14:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-17 14:49 Piotr Ziecik [this message]
2008-11-24 10:09 ` [U-Boot] [PATCH] flash: Add interface for flash verbosity control Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1226933372-21393-1-git-send-email-kosmo@semihalf.com \
    --to=kosmo@semihalf.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.