[rtems commit] LEON3: debugputs removed pointless isinit code,

Gedare Bloom gedare at rtems.org
Thu Apr 19 16:31:41 UTC 2012


  invoked only once
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Module:    rtems
Branch:    master
Commit:    605b4b649d286d88ed12eb50e18f76323ef9bee5
Changeset: http://git.rtems.org/rtems/commit/?id=605b4b649d286d88ed12eb50e18f76323ef9bee5

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Thu Apr 19 15:21:24 2012 +0200

LEON3: debugputs removed pointless isinit code, invoked only once

Signed-off-by: Daniel Hellstrom <daniel at gaisler.com>

---

 c/src/lib/libbsp/sparc/leon3/console/debugputs.c |   60 +++++++++------------
 1 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
index a189f5b..7058cf8 100644
--- a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
+++ b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
@@ -21,8 +21,6 @@
 #include <assert.h>
 #include <stdio.h>
 
-static int isinit = 0;
-
 /* Let user override which on-chip APBUART will be debug UART
  * 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
  * 1 = APBUART[0]
@@ -50,44 +48,38 @@ int bsp_debug_uart_init(void)
   struct ambapp_dev *adev;
   struct ambapp_apb_info *apb;
 
-  if (isinit == 0) {
-    /* Update debug_uart_index to index used as debug console.
-     * Let user select Debug console by setting debug_uart_index. If the
-     * BSP is to provide the default UART (debug_uart_index==0):
-     *   non-MP: APBUART[0] is debug console
-     *   MP: LEON CPU index select UART
-     */
-    if (debug_uart_index == 0) {
+  /* Update debug_uart_index to index used as debug console.
+   * Let user select Debug console by setting debug_uart_index. If the
+   * BSP is to provide the default UART (debug_uart_index==0):
+   *   non-MP: APBUART[0] is debug console
+   *   MP: LEON CPU index select UART
+   */
+  if (debug_uart_index == 0) {
 #if defined(RTEMS_MULTIPROCESSING)
-      debug_uart_index = LEON3_Cpu_Index;
+    debug_uart_index = LEON3_Cpu_Index;
 #else
-      debug_uart_index = 0;
+    debug_uart_index = 0;
 #endif
-    } else {
-      debug_uart_index = debug_uart_index - 1; /* User selected dbg-console */
-    }
-
-    /* Find APBUART core for System Debug Console */
-    i = debug_uart_index;
-    adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
-                                   VENDOR_GAISLER, GAISLER_APBUART,
-                                   ambapp_find_by_idx, (void *)&i);
-    if (adev) {
-      /* Found a matching debug console, initialize debug uart if present
-       * for printk
-       */
-      apb = (struct ambapp_apb_info *)adev->devinfo;
-      dbg_uart = (ambapp_apb_uart *)apb->start;
-      dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
-      dbg_uart->status = 0;
-    }
-    isinit = 1;
+  } else {
+    debug_uart_index = debug_uart_index - 1; /* User selected dbg-console */
   }
 
-  if (dbg_uart == NULL)
-    return 0;
-  else
+  /* Find APBUART core for System Debug Console */
+  i = debug_uart_index;
+  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+                                 VENDOR_GAISLER, GAISLER_APBUART,
+                                 ambapp_find_by_idx, (void *)&i);
+  if (adev) {
+    /* Found a matching debug console, initialize debug uart if present
+     * for printk
+     */
+    apb = (struct ambapp_apb_info *)adev->devinfo;
+    dbg_uart = (ambapp_apb_uart *)apb->start;
+    dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
+    dbg_uart->status = 0;
     return 1;
+  } else
+    return 0;
 }
 
 /*




More information about the vc mailing list