summaryrefslogtreecommitdiffstats
path: root/common/memory.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-03-03 11:47:44 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-06 11:41:29 +0100
commit3d554f9925941d99d646e5435bd1173ae19b85e2 (patch)
tree56d84f961ddfe7f552ba941de1128286eecb1ac9 /common/memory.c
parent8f458074e7ab270271a7caa48d81e4980fef5f34 (diff)
downloadbarebox-3d554f9925941d99d646e5435bd1173ae19b85e2.tar.gz
of: memory: Use of_write_number
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/memory.c')
-rw-r--r--common/memory.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/common/memory.c b/common/memory.c
index 1d2e3a3..61cca0d 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -164,19 +164,6 @@ int release_sdram_region(struct resource *res)
#ifdef CONFIG_OFTREE
-/*
- * Write a 4 or 8 byte big endian cell
- */
-static void write_cell(u8 *addr, u64 val, int size)
-{
- int shift = (size - 1) * 8;
-
- while (size-- > 0) {
- *addr++ = (val >> shift) & 0xff;
- shift -= 8;
- }
-}
-
static int of_memory_fixup(struct device_node *node)
{
struct memory_bank *bank;
@@ -193,14 +180,14 @@ static int of_memory_fixup(struct device_node *node)
if (err)
return err;
- addr_cell_len = of_n_addr_cells(memnode) * 4;
- size_cell_len = of_n_size_cells(memnode) * 4;
+ addr_cell_len = of_n_addr_cells(memnode);
+ size_cell_len = of_n_size_cells(memnode);
for_each_memory_bank(bank) {
- write_cell(tmp + len, bank->start, addr_cell_len);
- len += addr_cell_len;
- write_cell(tmp + len, bank->size, size_cell_len);
- len += size_cell_len;
+ of_write_number(tmp + len, bank->start, addr_cell_len);
+ len += addr_cell_len * 4;
+ of_write_number(tmp + len, bank->size, size_cell_len);
+ len += size_cell_len * 4;
}
err = of_set_property(memnode, "reg", tmp, len, 1);