diff mbox

[U-Boot,12/56] PM520: add missing enable_interrupts()

Message ID 1320458160-23136-13-git-send-email-wd@denx.de
State Accepted
Commit 17834a5c63b7a4327205107d9d3e689326f527a4
Headers show

Commit Message

Wolfgang Denk Nov. 5, 2011, 1:55 a.m. UTC
The code disabled interrupts in several locations, without re-enabling
them again.  Fix this.

While we are at it, also fix a GCC 4.6 build warning:
flash.c: In function 'flash_erase':
flash.c:373:21: warning: variable 'last' set but not used
[-Wunused-but-set-variable]

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Josef Wagner <Wagner@Microsys.de>
---
 board/pm520/flash.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

Comments

Wolfgang Denk Nov. 7, 2011, 9:11 p.m. UTC | #1
Dear Wolfgang Denk,

In message <1320458160-23136-13-git-send-email-wd@denx.de> you wrote:
> The code disabled interrupts in several locations, without re-enabling
> them again.  Fix this.
> 
> While we are at it, also fix a GCC 4.6 build warning:
> flash.c: In function 'flash_erase':
> flash.c:373:21: warning: variable 'last' set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Cc: Josef Wagner <Wagner@Microsys.de>
> ---
>  board/pm520/flash.c |   17 ++++++++++++-----
>  1 files changed, 12 insertions(+), 5 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/board/pm520/flash.c b/board/pm520/flash.c
index 64c8624..01dcd56 100644
--- a/board/pm520/flash.c
+++ b/board/pm520/flash.c
@@ -370,7 +370,7 @@  static unsigned char intel_sector_protected (flash_info_t *info, ushort sector)
 int flash_erase (flash_info_t *info, int s_first, int s_last)
 {
 	int flag, prot, sect;
-	ulong type, start, last;
+	ulong type, start;
 	int rcode = 0;
 
 	if ((s_first < 0) || (s_first > s_last)) {
@@ -404,7 +404,6 @@  int flash_erase (flash_info_t *info, int s_first, int s_last)
 	}
 
 	start = get_timer (0);
-	last = start;
 
 	/* Disable interrupts which might cause a timeout here */
 	flag = disable_interrupts ();
@@ -440,6 +439,10 @@  int flash_erase (flash_info_t *info, int s_first, int s_last)
 			printf (" done\n");
 		}
 	}
+
+	if (flag)
+		enable_interrupts();
+
 	return rcode;
 }
 
@@ -543,6 +546,7 @@  static int write_data (flash_info_t *info, ulong dest, FPW data)
 	ulong status;
 	ulong start;
 	int flag;
+	int rcode = 0;
 
 	/* Check if Flash is (sufficiently) erased */
 	if ((*addr & data) != data) {
@@ -561,14 +565,17 @@  static int write_data (flash_info_t *info, ulong dest, FPW data)
 	/* wait while polling the status register */
 	while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
 		if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-			*addr = (FPW) 0x00FF00FF;	/* restore read mode */
-			return (1);
+			rcode = 1;
+			break;
 		}
 	}
 
 	*addr = (FPW) 0x00FF00FF;	/* restore read mode */
 
-	return (0);
+	if (flag)
+		enable_interrupts();
+
+	return rcode;
 }
 
 void inline spin_wheel (void)