From: Oliver Schinagl <oli...@schinagl.nl>

One of the parameters that gets passed to the Linux kernel is the
physical continuous RAM size. The type for this datum is phys_size_t
which is hiding its real data type, unsigned long.

get_ram_size however returns long and thus can not only report negative
memory, it also clashes with pyhs_size_t.

This patch converts get_ram_size to take and return unsigned long's over
signed longs.

Signed-off-by: Oliver Schinagl <oli...@schinagl.nl>
---
 common/memsize.c | 24 ++++++++++++------------
 include/common.h |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/common/memsize.c b/common/memsize.c
index 73b92c8..617907d 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -21,16 +21,16 @@
  * the actually available RAM size between addresses `base' and
  * `base + maxsize'.
  */
-long get_ram_size(long *base, long maxsize)
+unsigned long get_ram_size(unsigned long *base, unsigned long maxsize)
 {
-       volatile long *addr;
-       long           save[32];
-       long           cnt;
-       long           val;
-       long           size;
-       int            i = 0;
+       volatile unsigned long *addr;
+       unsigned long           save[32];
+       unsigned long           cnt;
+       unsigned long           val;
+       unsigned long           size;
+       int                     i = 0;
 
-       for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+       for (cnt = (maxsize / sizeof (unsigned long)) >> 1; cnt > 0; cnt >>= 1) 
{
                addr = base + cnt;      /* pointer arith! */
                sync ();
                save[i++] = *addr;
@@ -50,7 +50,7 @@ long get_ram_size(long *base, long maxsize)
                 */
                sync ();
                *addr = save[i];
-               for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+               for (cnt = 1; cnt < maxsize / sizeof(unsigned long); cnt <<= 1) 
{
                        addr  = base + cnt;
                        sync ();
                        *addr = save[--i];
@@ -58,15 +58,15 @@ long get_ram_size(long *base, long maxsize)
                return (0);
        }
 
-       for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+       for (cnt = 1; cnt < maxsize / sizeof (unsigned long); cnt <<= 1) {
                addr = base + cnt;      /* pointer arith! */
                val = *addr;
                *addr = save[--i];
                if (val != ~cnt) {
-                       size = cnt * sizeof (long);
+                       size = cnt * sizeof (unsigned long);
                        /* Restore the original data before leaving the 
function.
                         */
-                       for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 
1) {
+                       for (cnt <<= 1; cnt < maxsize / sizeof (unsigned long); 
cnt <<= 1) {
                                addr  = base + cnt;
                                *addr = save[--i];
                        }
diff --git a/include/common.h b/include/common.h
index 8addf43..e8a3547 100644
--- a/include/common.h
+++ b/include/common.h
@@ -453,7 +453,7 @@ const char *symbol_lookup(unsigned long addr, unsigned long 
*caddr);
 void   api_init (void);
 
 /* common/memsize.c */
-long   get_ram_size  (long *, long);
+unsigned long  get_ram_size  (unsigned long *, unsigned long);
 
 /* $(BOARD)/$(BOARD).c */
 void   reset_phy     (void);
-- 
1.8.3.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to