mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	barebox@lists.infradead.org
Subject: Re: [PATCH] of: add ranges address translation for default bus
Date: Sun, 19 May 2013 09:34:03 +0200	[thread overview]
Message-ID: <20130519073403.GY32299@pengutronix.de> (raw)
In-Reply-To: <1368400146-30443-1-git-send-email-sebastian.hesselbarth@gmail.com>

Hi Sebastian,

On Mon, May 13, 2013 at 01:09:06AM +0200, Sebastian Hesselbarth wrote:
> This patch adds address translation for default bus types. It has been
> shamelessly ported from Linux device tree address translation with the
> following exceptions:
> - only default bus map and translate are supported
> - of_bus has not been ported
> - check for #size-cells > 0 has been removed
> 
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

I just gave this one a test.

First of all you dropped 1:1 translation, see the attached fixup.

Then, since this code duplicates the majority of drivers/of/address.c,
would it make sense to move it to the same file in barebox aswell?

Sascha

8<---------------------------------------------------------
From bb502b1154a135f7aead65858ffa420f3d3e2df3 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Sun, 19 May 2013 09:28:56 +0200
Subject: [PATCH] fixup! of: add ranges address translation for default bus

Fix 1:1 translation using empty ranges property

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

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5d449d1..7f3b76d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -260,11 +260,21 @@ static int of_translate_one(struct device_node *parent,
 	unsigned int rlen;
 	int rone;
 	u64 offset = OF_BAD_ADDR;
+	struct property *prop = of_find_property(parent, rprop);
 
-	ranges = of_get_property(parent, rprop, &rlen);
-	if (!ranges)
+	if (!prop)
 		return 1;
 
+	rlen = prop->length;
+	ranges = prop->value;
+
+	if (rlen == 0) {
+		/* empty ranges; 1:1 translation */
+		offset = of_read_number(addr, na);
+		memset(addr, 0, pna * 4);
+		goto finish;
+	}
+
 	/* walk through ranges */
 	rlen /= 4;
 	rone = na + pna + ns;
@@ -277,6 +287,7 @@ static int of_translate_one(struct device_node *parent,
 		return 1;
 
 	memcpy(addr, ranges + na, 4 * pna);
+finish:
 	/* translate into parent address space */
 	return of_bus_default_translate(addr, offset, pna);
 }
-- 
1.8.2.rc2


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  reply	other threads:[~2013-05-19  7:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-12 23:09 Sebastian Hesselbarth
2013-05-19  7:34 ` Sascha Hauer [this message]
2013-05-19  8:07   ` Sebastian Hesselbarth
2013-05-19 10:39     ` Sascha Hauer
2013-05-19 10:49       ` Sebastian Hesselbarth
2013-05-19 15:20         ` Thomas Petazzoni
2013-06-11  9:33   ` Sebastian Hesselbarth
2013-06-13  9:25     ` Sascha Hauer
2013-06-13  9:38       ` Sebastian Hesselbarth
2013-06-13 12:48         ` Sascha Hauer
2013-06-13 18:50           ` Sebastian Hesselbarth
2013-06-17  7:47             ` Sascha Hauer
2013-06-17 10:23               ` Sebastian Hesselbarth
2013-06-17 10:40                 ` 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=20130519073403.GY32299@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=thomas.petazzoni@free-electrons.com \
    /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