changeset 2633:592d727733df

* src/flash.c (cyg_flash_init): Allow repeated calls to change the printf function for all devices. There are times you don't any output, eg you are downloading an image over the serial port.
author jlarmour
date Tue, 18 Nov 2008 01:57:58 +0000
parents 8efe2e4d41ee
children 6ababf0a3ff2
files packages/io/flash/current/ChangeLog packages/io/flash/current/src/flash.c
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/flash/current/ChangeLog
+++ b/packages/io/flash/current/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-18  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/flash.c (cyg_flash_init): Allow repeated calls to
+	change the printf function for all devices. There are
+	times you don't any output, eg you are downloading an
+	image over the serial port.
+
 2008-08-29  Nick Garnett  <nickg@ecoscentric.com>
 
 	* src/flashiodev.c (flashiodev_init): Assign
--- a/packages/io/flash/current/src/flash.c
+++ b/packages/io/flash/current/src/flash.c
@@ -223,10 +223,16 @@ cyg_flash_init(cyg_flash_printf *pf)
   int err;
   struct cyg_flash_dev * dev;
   
-  if (init) return CYG_FLASH_ERR_OK;
-
   CYG_ASSERT(&(cyg_flashdevtab[CYGHWR_IO_FLASH_DEVICE]) == &cyg_flashdevtab_end, "incorrect number of flash devices");
   
+  if (init) {
+      // In case the printf function has changed.
+      for (dev = &cyg_flashdevtab[0]; dev != &cyg_flashdevtab_end; dev++) {
+          dev->pf = pf;
+      }
+      return CYG_FLASH_ERR_OK;
+  }
+
   for (dev = &cyg_flashdevtab[0]; dev != &cyg_flashdevtab_end; dev++) {
     dev->pf = pf;
     LOCK_INIT(dev);