These struct members do not have more info than what's already in the
resource, so just drop them, so code doesn't have to keep them in-sync.

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 arch/arm/cpu/mmu-common.c |  4 ++--
 arch/arm/lib32/atags.c    |  6 +++---
 arch/arm/lib32/bootm.c    |  6 +++---
 arch/arm/lib32/bootz.c    | 10 +++++-----
 commands/bfetch.c         |  2 +-
 common/memory.c           | 18 +++++++-----------
 include/memory.h          |  2 --
 7 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c
index b3d9e9579686..227ae4aa34e6 100644
--- a/arch/arm/cpu/mmu-common.c
+++ b/arch/arm/cpu/mmu-common.c
@@ -145,7 +145,7 @@ static void mmu_remap_memory_banks(void)
                struct resource *rsv;
                resource_size_t pos;
 
-               pos = bank->start;
+               pos = bank->res->start;
 
                /* Skip reserved regions */
                for_each_reserved_region(bank, rsv) {
@@ -154,7 +154,7 @@ static void mmu_remap_memory_banks(void)
                        pos = rsv->end + 1;
                }
 
-               remap_range_end_sans_text(pos, bank->start + bank->size, 
MAP_CACHED);
+               remap_range_end_sans_text(pos, bank->res->end + 1, MAP_CACHED);
        }
 
        /* Do this while interrupt vectors are still writable */
diff --git a/arch/arm/lib32/atags.c b/arch/arm/lib32/atags.c
index d567a13563b6..4af97f001855 100644
--- a/arch/arm/lib32/atags.c
+++ b/arch/arm/lib32/atags.c
@@ -74,7 +74,7 @@ struct tag *armlinux_get_bootparams(void)
                return armlinux_bootparams;
 
        for_each_memory_bank(mem)
-               return (void *)mem->start + 0x100;
+               return (void *)mem->res->start + 0x100;
 
        BUG();
 }
@@ -110,8 +110,8 @@ static void setup_memory_tags(void)
                params->hdr.tag = ATAG_MEM;
                params->hdr.size = tag_size(tag_mem32);
 
-               params->u.mem.start = bank->start;
-               params->u.mem.size = bank->size;
+               params->u.mem.start = bank->res->start;
+               params->u.mem.size = resource_size(bank->res);
 
                params = tag_next(params);
        }
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index 69ca6d31d6c5..dca4fec0204c 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -66,11 +66,11 @@ static int sdram_start_and_size(unsigned long *start, 
unsigned long *size)
        res = list_first_entry_or_null(&bank->res->children, struct resource,
                        sibling);
        if (res)
-               *size = res->start - bank->start;
+               *size = res->start - bank->res->start;
        else
-               *size = bank->size;
+               *size = resource_size(bank->res);
 
-       *start = bank->start;
+       *start = bank->res->start;
 
        return 0;
 }
diff --git a/arch/arm/lib32/bootz.c b/arch/arm/lib32/bootz.c
index ddc53431ebd3..6ed6af1d19e3 100644
--- a/arch/arm/lib32/bootz.c
+++ b/arch/arm/lib32/bootz.c
@@ -48,8 +48,8 @@ static int do_bootz(int argc, char *argv[])
         * the first 128MB of SDRAM.
         */
        zimage = memmap(fd, PROT_READ);
-       if (zimage && (unsigned long)zimage  >= bank->start &&
-                       (unsigned long)zimage < bank->start + SZ_128M) {
+       if (zimage && (unsigned long)zimage  >= bank->res->start &&
+                       (unsigned long)zimage < bank->res->start + SZ_128M) {
                usemap = 1;
                header = zimage;
        }
@@ -82,12 +82,12 @@ static int do_bootz(int argc, char *argv[])
                end = swab32(end);
 
        if (!usemap) {
-               if (bank->size <= SZ_128M) {
+               if (resource_size(bank->res) <= SZ_128M) {
                        zimage = xmalloc(end);
                } else {
-                       zimage = (void *)bank->start + SZ_8M;
+                       zimage = (void *)bank->res->start + SZ_8M;
                        res = request_sdram_region("zimage",
-                                       bank->start + SZ_8M, end,
+                                       bank->res->start + SZ_8M, end,
                                        MEMTYPE_LOADER_CODE,
                                        MEMATTRS_RWX);
                        if (!res) {
diff --git a/commands/bfetch.c b/commands/bfetch.c
index 4de6513ff08e..4de4692a6278 100644
--- a/commands/bfetch.c
+++ b/commands/bfetch.c
@@ -271,7 +271,7 @@ static struct bobject *print_cpu_mem_info(unsigned *line)
        }
 
        for_each_memory_bank(mem) {
-               memsize += mem->size;
+               memsize += resource_size(mem->res);
                nbanks++;
        }
 
diff --git a/common/memory.c b/common/memory.c
index bee55bd647e1..f179a3243ff1 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -185,8 +185,8 @@ static int barebox_grow_memory_bank(struct memory_bank 
*bank, const char *name,
        struct resource *res;
        resource_size_t bank_end = bank->res->end;
 
-       if (newres->start < bank->start) {
-               res = request_iomem_region(name, newres->start, bank->start - 
1);
+       if (newres->start < bank->res->start) {
+               res = request_iomem_region(name, newres->start, 
bank->res->start - 1);
                if (IS_ERR(res))
                        return PTR_ERR(res);
                __merge_regions(name, bank->res, res);
@@ -199,9 +199,6 @@ static int barebox_grow_memory_bank(struct memory_bank 
*bank, const char *name,
                __merge_regions(name, bank->res, res);
        }
 
-       bank->start = newres->start;
-       bank->size = resource_size(bank->res);
-
        return 0;
 }
 
@@ -232,8 +229,6 @@ int barebox_add_memory_bank(const char *name, 
resource_size_t start,
        bank = xzalloc(sizeof(*bank));
 
        bank->res = res;
-       bank->start = start;
-       bank->size = size;
 
        list_add_tail(&bank->list, &memory_banks);
 
@@ -245,7 +240,8 @@ static int add_mem_devices(void)
        struct memory_bank *bank;
 
        for_each_memory_bank(bank) {
-               add_mem_device(bank->res->name, bank->start, bank->size,
+               add_mem_device(bank->res->name,
+                              bank->res->start, resource_size(bank->res),
                               IORESOURCE_MEM_WRITEABLE);
        }
 
@@ -400,7 +396,7 @@ static int of_memory_fixup(struct device_node *root, void 
*unused)
                int len = 0;
 
                /* Create a /memory node for each bank */
-               memnode_name = xasprintf("/memory@%lx", bank->start);
+               memnode_name = xasprintf("/memory@%llx", (u64)bank->res->start);
 
                memnode = of_create_node(root, memnode_name);
                if (!memnode) {
@@ -413,9 +409,9 @@ static int of_memory_fixup(struct device_node *root, void 
*unused)
                if (err)
                        goto err_free;
 
-               of_write_number(tmp, bank->start, addr_cell_len);
+               of_write_number(tmp, bank->res->start, addr_cell_len);
                len += addr_cell_len * 4;
-               of_write_number(tmp + len, bank->size, size_cell_len);
+               of_write_number(tmp + len, resource_size(bank->res), 
size_cell_len);
                len += size_cell_len * 4;
 
                err = of_set_property(memnode, "reg", tmp, len, 1);
diff --git a/include/memory.h b/include/memory.h
index 12dd4220422c..dea76dd2b1f7 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -17,8 +17,6 @@ static inline ulong mem_malloc_size(void)
 
 struct memory_bank {
        struct list_head list;
-       unsigned long start;
-       unsigned long size;
        struct resource *res;
 };
 
-- 
2.47.3


Reply via email to