init_sequence is an array with function pointers which
are really hard to follow when you need to debug this area.
Turn it into plain function calls instead which makes
the code a bit uglier but I find the simpler debugging
much more valuable.

An added bonus is that it is smaller too:
   text    data     bss     dec     hex filename
   1268     212       0    1480     5c8 lib_ppc/board.org
   1224      92       0    1316     524 lib_ppc/board.new

Signed-off-by: Joakim Tjernlund <joakim.tjernl...@transmode.se>
---

 So I had to do debug this area again and I am getting really
 tiered of following function pointers so here goes
 my old patch again.

 arch/powerpc/lib/board.c |  123 
+++++++++++++++++++++++++++++++++---------------------
 1 files changed, 75 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 765f97a..f0160e6 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -157,7 +157,6 @@ ulong monitor_flash_len;
  * argument, and returns an integer return code, where 0 means
  * "continue" and != 0 means "fatal error, hang the system".
  */
-typedef int (init_fnc_t) (void);
 
 /************************************************************************
  * Init Utilities                                                      *
@@ -236,17 +235,17 @@ static int init_func_watchdog_init (void)
        WATCHDOG_RESET ();
        return (0);
 }
-# define INIT_FUNC_WATCHDOG_INIT       init_func_watchdog_init,
+# define INIT_FUNC_WATCHDOG_INIT       init_func_watchdog_init()
 
 static int init_func_watchdog_reset (void)
 {
        WATCHDOG_RESET ();
        return (0);
 }
-# define INIT_FUNC_WATCHDOG_RESET      init_func_watchdog_reset,
+# define INIT_FUNC_WATCHDOG_RESET      init_func_watchdog_reset()
 #else
-# define INIT_FUNC_WATCHDOG_INIT       /* undef */
-# define INIT_FUNC_WATCHDOG_RESET      /* undef */
+# define INIT_FUNC_WATCHDOG_INIT       0 /* undef */
+# define INIT_FUNC_WATCHDOG_RESET      0 /* undef */
 #endif /* CONFIG_WATCHDOG */
 
 /************************************************************************
@@ -254,76 +253,110 @@ static int init_func_watchdog_reset (void)
  ************************************************************************
  */
 
-init_fnc_t *init_sequence[] = {
+void init_sequence(void)
+{
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
-       probecpu,
+       if (probecpu())
+               goto err_out;
 #endif
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
-       board_early_init_f,
+       if (board_early_init_f())
+               goto err_out;
 #endif
 #if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
-       get_clocks,             /* get CPU and bus clocks (etc.) */
+       if (get_clocks())
+               goto err_out;   /* get CPU and bus clocks (etc.) */
 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
     && !defined(CONFIG_TQM885D)
-       adjust_sdram_tbs_8xx,
+       if (adjust_sdram_tbs_8xx())
+               goto err_out;
 #endif
-       init_timebase,
+       if (init_timebase())
+               goto err_out;
 #endif
 #ifdef CONFIG_SYS_ALLOC_DPRAM
 #if !defined(CONFIG_CPM2)
-       dpram_init,
+       if (dpram_init())
+               goto err_out;
 #endif
 #endif
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
-       board_postclk_init,
+       if (board_postclk_init())
+               goto err_out;
 #endif
-       env_init,
+       if (env_init())
+               goto err_out;
 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
-       get_clocks_866,         /* get CPU and bus clocks according to the 
environment variable */
-       sdram_adjust_866,       /* adjust sdram refresh rate according to the 
new clock */
-       init_timebase,
-#endif
-       init_baudrate,
-       serial_init,
-       console_init_f,
-       display_options,
+       if (get_clocks_866())
+               goto err_out;   /* get CPU and bus clocks according to the 
environment variable */
+       if (sdram_adjust_866())
+               goto err_out;   /* adjust sdram refresh rate according to the 
new clock */
+       if (init_timebase())
+               goto err_out;
+#endif
+       if (init_baudrate())
+               goto err_out;
+       if (serial_init())
+               goto err_out;
+       if (console_init_f())
+               goto err_out;
+       if (display_options())
+               goto err_out;
 #if defined(CONFIG_8260)
-       prt_8260_rsr,
-       prt_8260_clks,
+       if (prt_8260_rsr())
+               goto err_out;
+       if (prt_8260_clks())
+               goto err_out;
 #endif /* CONFIG_8260 */
 #if defined(CONFIG_MPC83xx)
-       prt_83xx_rsr,
+       if (prt_83xx_rsr())
+               goto err_out;
 #endif
-       checkcpu,
+       if (checkcpu())
+               goto err_out;
 #if defined(CONFIG_MPC5xxx)
-       prt_mpc5xxx_clks,
+       if (prt_mpc5xxx_clks())
+               goto err_out;
 #endif /* CONFIG_MPC5xxx */
 #if defined(CONFIG_MPC8220)
-       prt_mpc8220_clks,
+       if (prt_mpc8220_clks())
+               goto err_out;
 #endif
-       checkboard,
-       INIT_FUNC_WATCHDOG_INIT
+       if (checkboard())
+               goto err_out;
+       if (INIT_FUNC_WATCHDOG_INIT)
+               goto err_out;
 #if defined(CONFIG_MISC_INIT_F)
-       misc_init_f,
+       if (misc_init_f())
+               goto err_out;
 #endif
-       INIT_FUNC_WATCHDOG_RESET
+       if (INIT_FUNC_WATCHDOG_RESET)
+               goto err_out;
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
-       init_func_i2c,
+       if (init_func_i2c())
+               goto err_out;
 #endif
 #if defined(CONFIG_HARD_SPI)
-       init_func_spi,
+       if (init_func_spi())
+               goto err_out;
 #endif
 #ifdef CONFIG_POST
-       post_init_f,
+       if (post_init_f())
+               goto err_out;
 #endif
-       INIT_FUNC_WATCHDOG_RESET
-       init_func_ram,
+       if (INIT_FUNC_WATCHDOG_RESET)
+               goto err_out;
+       if (init_func_ram())
+               goto err_out;
 #if defined(CONFIG_SYS_DRAM_TEST)
-       testdram,
+       if (testdram())
+               goto err_out;
 #endif /* CONFIG_SYS_DRAM_TEST */
-       INIT_FUNC_WATCHDOG_RESET
-
-       NULL,                   /* Terminate this list */
+       if (INIT_FUNC_WATCHDOG_RESET)
+               goto err_out;
+       return;
+err_out:
+       hang();
 };
 
 ulong get_effective_memsize(void)
@@ -366,7 +399,6 @@ void board_init_f (ulong bootflag)
        ulong len, addr, addr_sp;
        ulong *s;
        gd_t *id;
-       init_fnc_t **init_fnc_ptr;
 #ifdef CONFIG_PRAM
        int i;
        ulong reg;
@@ -383,12 +415,7 @@ void board_init_f (ulong bootflag)
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
 #endif
-
-       for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-               if ((*init_fnc_ptr) () != 0) {
-                       hang ();
-               }
-       }
+       init_sequence();
 
        /*
         * Now that we have DRAM mapped and working, we can
-- 
1.6.4.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to