summaryrefslogtreecommitdiff
path: root/common/memsize.c
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2018-01-25 18:07:45 +0100
committerTom Rini <trini@konsulko.com>2018-03-13 21:59:30 -0400
commitc5da05cd412e1656fe3d1909966013fc121c5c5c (patch)
tree4f046e069170e7ddd4e976a599738e32364c604f /common/memsize.c
parent79717c8047cfe9a6a4c06ee839ef5f94c0fb5406 (diff)
common/memsize.c: prepare get_ram_size update
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>
Diffstat (limited to 'common/memsize.c')
-rw-r--r--common/memsize.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/memsize.c b/common/memsize.c
index 0fb9ba57b6..6dc4bb21b0 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();