[U-Boot] [PATCH 17/21] sh: Unify duplicate reset code

Kyle Moffett Kyle.D.Moffett at boeing.com
Mon Mar 7 18:37:38 CET 2011


All 3 SH processor variants have the same do_reset() and reset_cpu()
function implementations.  Furthermore, the only caller of the
reset_cpu() function on SH is do_reset().

To simplify and prepare for SH generic-restart support this patch
removes 38 lines of code by merging the functions together and moving
them into common code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett at boeing.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
---
 arch/sh/cpu/sh2/cpu.c      |    7 -------
 arch/sh/cpu/sh2/watchdog.c |    9 ---------
 arch/sh/cpu/sh3/cpu.c      |    7 -------
 arch/sh/cpu/sh3/watchdog.c |    9 ---------
 arch/sh/cpu/sh4/cpu.c      |    7 -------
 arch/sh/cpu/sh4/watchdog.c |    9 ---------
 arch/sh/lib/board.c        |   10 ++++++++++
 7 files changed, 10 insertions(+), 48 deletions(-)

diff --git a/arch/sh/cpu/sh2/cpu.c b/arch/sh/cpu/sh2/cpu.c
index 6bbedd9..a88fcad 100644
--- a/arch/sh/cpu/sh2/cpu.c
+++ b/arch/sh/cpu/sh2/cpu.c
@@ -59,13 +59,6 @@ int cleanup_before_linux(void)
 	return 0;
 }
 
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	disable_interrupts();
-	reset_cpu(0);
-	return 0;
-}
-
 void flush_cache(unsigned long addr, unsigned long size)
 {
 
diff --git a/arch/sh/cpu/sh2/watchdog.c b/arch/sh/cpu/sh2/watchdog.c
index 0257d8d..df7f263 100644
--- a/arch/sh/cpu/sh2/watchdog.c
+++ b/arch/sh/cpu/sh2/watchdog.c
@@ -26,12 +26,3 @@ int watchdog_init(void)
 {
 	return 0;
 }
-
-void reset_cpu(unsigned long ignored)
-{
-	/* Address error with SR.BL=1 first. */
-	trigger_address_error();
-
-	while (1)
-		;
-}
diff --git a/arch/sh/cpu/sh3/cpu.c b/arch/sh/cpu/sh3/cpu.c
index 3e9caad..824daab 100644
--- a/arch/sh/cpu/sh3/cpu.c
+++ b/arch/sh/cpu/sh3/cpu.c
@@ -45,13 +45,6 @@ int cleanup_before_linux(void)
 	return 0;
 }
 
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	disable_interrupts();
-	reset_cpu(0);
-	return 0;
-}
-
 void flush_cache(unsigned long addr, unsigned long size)
 {
 
diff --git a/arch/sh/cpu/sh3/watchdog.c b/arch/sh/cpu/sh3/watchdog.c
index 90694f8..1dff27a 100644
--- a/arch/sh/cpu/sh3/watchdog.c
+++ b/arch/sh/cpu/sh3/watchdog.c
@@ -29,12 +29,3 @@ int watchdog_init(void)
 {
 	return 0;
 }
-
-void reset_cpu(unsigned long ignored)
-{
-	/* Address error with SR.BL=1 first. */
-	trigger_address_error();
-
-	while (1)
-		;
-}
diff --git a/arch/sh/cpu/sh4/cpu.c b/arch/sh/cpu/sh4/cpu.c
index f136758..264dafb 100644
--- a/arch/sh/cpu/sh4/cpu.c
+++ b/arch/sh/cpu/sh4/cpu.c
@@ -44,13 +44,6 @@ int cleanup_before_linux (void)
 	return 0;
 }
 
-int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	disable_interrupts();
-	reset_cpu (0);
-	return 0;
-}
-
 void flush_cache (unsigned long addr, unsigned long size)
 {
 	dcache_invalid_range( addr , addr + size );
diff --git a/arch/sh/cpu/sh4/watchdog.c b/arch/sh/cpu/sh4/watchdog.c
index d7e1703..cbc08f8 100644
--- a/arch/sh/cpu/sh4/watchdog.c
+++ b/arch/sh/cpu/sh4/watchdog.c
@@ -64,12 +64,3 @@ int watchdog_disable(void)
 	return 0;
 }
 #endif
-
-void reset_cpu(unsigned long ignored)
-{
-	/* Address error with SR.BL=1 first. */
-	trigger_address_error();
-
-	while (1)
-		;
-}
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 968566c..07361b4 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -204,6 +204,16 @@ void sh_generic_init(void)
 
 /***********************************************************************/
 
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	disable_interrupts();
+
+	/* Address error with SR.BL=1 first. */
+	trigger_address_error();
+
+	while (1);
+}
+
 void hang(void)
 {
 	puts("Board ERROR\n");
-- 
1.7.2.3



More information about the U-Boot mailing list