]> git.sur5r.net Git - u-boot/commitdiff
common/memsize.c: prepare get_ram_size update
authorPatrick Delaunay <patrick.delaunay@st.com>
Thu, 25 Jan 2018 17:07:45 +0000 (18:07 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 14 Mar 2018 01:59:30 +0000 (21:59 -0400)
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>
common/memsize.c

index 0fb9ba57b62b21d99df1fc8214c67a0016d1e63b..6dc4bb21b01e18e4079df7f3c8a06744dd0bc562 100644 (file)
@@ -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();