[PATCH 32/37] of: memory: Use of_write_number

Sascha Hauer s.hauer at pengutronix.de
Mon Mar 4 04:53:35 EST 2013


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/memory.c |   25 ++++++-------------------
 1 file 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);
-- 
1.7.10.4




More information about the barebox mailing list