diff mbox series

[U-Boot,v2,1/2] common/memsize.c: prepare get_ram_size update

Message ID 1516900066-23456-2-git-send-email-patrick.delaunay@st.com
State Accepted
Commit c5da05cd412e1656fe3d1909966013fc121c5c5c
Delegated to: Tom Rini
Headers show
Series common/memsize.c: restore content of the base address | expand

Commit Message

Patrick DELAUNAY Jan. 25, 2018, 5:07 p.m. UTC
Save the content of the base address in a new variable
in stack (save_base) to prepare restore this content.

This patch don't modified code behavior and stack usage.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v2:
- Split patch in 2 part to more easily understood regression

 common/memsize.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Tom Rini March 14, 2018, 2:07 p.m. UTC | #1
On Thu, Jan 25, 2018 at 06:07:45PM +0100, Patrick Delaunay wrote:

> Save the content of the base address in a new variable
> in stack (save_base) to prepare restore this content.
> 
> This patch don't modified code behavior and stack usage.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/memsize.c b/common/memsize.c
index 0fb9ba5..6dc4bb2 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -27,7 +27,8 @@  DECLARE_GLOBAL_DATA_PTR;
 long get_ram_size(long *base, long maxsize)
 {
 	volatile long *addr;
-	long           save[32];
+	long           save[31];
+	long           save_base;
 	long           cnt;
 	long           val;
 	long           size;
@@ -43,7 +44,7 @@  long get_ram_size(long *base, long maxsize)
 
 	addr = base;
 	sync();
-	save[i] = *addr;
+	save_base = *addr;
 	sync();
 	*addr = 0;
 
@@ -51,7 +52,7 @@  long get_ram_size(long *base, long maxsize)
 	if ((val = *addr) != 0) {
 		/* Restore the original data before leaving the function. */
 		sync();
-		*addr = save[i];
+		*base = save_base;
 		for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
 			addr  = base + cnt;
 			sync();