mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] memory: return error in barebox_add_memory_bank
Date: Mon,  8 Oct 2012 21:46:20 +0200	[thread overview]
Message-ID: <1349725584-20509-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1349725584-20509-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 common/memory.c  |    8 +++++---
 include/memory.h |    2 +-
 2 files changed, 6 insertions(+), 4 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;
 }
 
 /*
diff --git a/include/memory.h b/include/memory.h
index 4be4340..165d2dc 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -18,7 +18,7 @@ struct memory_bank {
 
 extern struct 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);
 
 #define for_each_memory_bank(mem)	list_for_each_entry(mem, &memory_banks, list)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-10-08 19:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 19:46 [PATCH] of patches Sascha Hauer
2012-10-08 19:46 ` Sascha Hauer [this message]
2012-10-08 19:46 ` [PATCH 2/5] of: find and register memory during probe Sascha Hauer
2012-10-08 19:46 ` [PATCH 3/5] console/of: evaluate linux,stdout-path property Sascha Hauer
2012-10-08 19:46 ` [PATCH 4/5] of: Add function to get the model name Sascha Hauer
2012-10-08 19:46 ` [PATCH 5/5] of: Print model name in banner Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349725584-20509-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox