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 4/6] of: read resource names from devicetree
Date: Mon, 22 Apr 2013 09:27:21 +0200	[thread overview]
Message-ID: <1366615643-22213-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1366615643-22213-1-git-send-email-s.hauer@pengutronix.de>

Resources can have names and these can also be specified in the
devicetree. Add support for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/base.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index b8c2e89..fde91b3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -919,8 +919,9 @@ static int add_of_device_resource(struct device_node *node)
 	struct resource *res, *resp;
 	struct device_d *dev;
 	const __be32 *endp, *reg;
+	const char *resname;
 	int na, nc, n_resources;
-	int ret, len;
+	int ret, len, index;
 
 	ret = of_add_memory(node, false);
 	if (ret != -ENXIO)
@@ -938,6 +939,8 @@ static int add_of_device_resource(struct device_node *node)
 
 	endp = reg + (len / sizeof(__be32));
 
+	index = 0;
+
 	while ((endp - reg) >= (na + nc)) {
 		address = of_translate_address(node, reg);
 		if (address == OF_BAD_ADDR) {
@@ -950,8 +953,13 @@ static int add_of_device_resource(struct device_node *node)
 
 		resp->start = address;
 		resp->end = address + size - 1;
+		resname = NULL;
+		of_property_read_string_index(node, "reg-names", index, &resname);
+		if (resname)
+			resp->name = xstrdup(resname);
 		resp->flags = IORESOURCE_MEM;
 		resp++;
+		index++;
         }
 
 	/*
-- 
1.8.2.rc2


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

  parent reply	other threads:[~2013-04-22  7:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22  7:27 [PATCH] devicetree patches Sascha Hauer
2013-04-22  7:27 ` [PATCH 1/6] of: parse phandles before probing devices Sascha Hauer
2013-04-22  7:27 ` [PATCH 2/6] of: Add of_property_read_string_index() Sascha Hauer
2013-04-22  7:27 ` [PATCH 3/6] of: Allow multiple resources in 'reg' property Sascha Hauer
2013-04-22  7:27 ` Sascha Hauer [this message]
2013-04-22  7:27 ` [PATCH 5/6] of: partitions: pass struct cdev as argument Sascha Hauer
2013-04-22  7:27 ` [PATCH 6/6] of: partitions: create bb device for nand flashes 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=1366615643-22213-5-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