summaryrefslogtreecommitdiffstats
path: root/common/memory.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-08 00:33:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-08 00:33:21 +0200
commitb36cc0f88452a1c4fba64559b15bbb87c6bd4f8a (patch)
tree0ef763a265c85ad55453a828ba46f0c52c4783e2 /common/memory.c
parentbad4d7cd754579cfe20cba4c721b2c1269bfa2d8 (diff)
downloadbarebox-b36cc0f88452a1c4fba64559b15bbb87c6bd4f8a.tar.gz
memory: return error in barebox_add_memory_bank
When a memory bank is already registered, return an error code instead of throwing a bug. This can happen if a board has registered a memory bank and the same bank is then probed from the devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/memory.c')
-rw-r--r--common/memory.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/common/memory.c b/common/memory.c
index 7174f14..2674002 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -113,15 +113,15 @@ void *sbrk(ptrdiff_t increment)
LIST_HEAD(memory_banks);
-void barebox_add_memory_bank(const char *name, resource_size_t start,
+int barebox_add_memory_bank(const char *name, resource_size_t start,
resource_size_t size)
{
struct memory_bank *bank = xzalloc(sizeof(*bank));
struct device_d *dev;
bank->res = request_iomem_region(name, start, start + size - 1);
-
- BUG_ON(!bank->res);
+ if (!bank->res)
+ return -EBUSY;
dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE);
@@ -130,6 +130,8 @@ void barebox_add_memory_bank(const char *name, resource_size_t start,
bank->size = size;
list_add_tail(&bank->list, &memory_banks);
+
+ return 0;
}
/*