All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Michal Simek <monstr@monstr.eu>,
	linuxppc-dev@ozlabs.org, microblaze-uclinux@itee.uq.edu.au
Subject: [PATCH 4/5] of/address: little-endian fixes
Date: Tue, 08 Jun 2010 08:10:13 -0600	[thread overview]
Message-ID: <20100608141013.25879.34892.stgit@angua> (raw)
In-Reply-To: <20100608140917.25879.67745.stgit@angua>

Fix some endian issues in the OF address translation code.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Michal Simek <monstr@monstr.eu>
CC: Wolfram Sang <w.sang@pengutronix.de>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: microblaze-uclinux@itee.uq.edu.au
CC: linuxppc-dev@ozlabs.org
---
 drivers/of/address.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 2a905d5..0b04137 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -22,7 +22,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na)
 {
 	printk(KERN_DEBUG "%s", s);
 	while (na--)
-		printk(" %08x", *(addr++));
+		printk(" %08x", be32_to_cpu(*(addr++)));
 	printk("\n");
 }
 #else
@@ -79,8 +79,8 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na)
 	memset(addr, 0, na * 4);
 	a += offset;
 	if (na > 1)
-		addr[na - 2] = a >> 32;
-	addr[na - 1] = a & 0xffffffffu;
+		addr[na - 2] = cpu_to_be32(a >> 32);
+	addr[na - 1] = cpu_to_be32(a & 0xffffffffu);
 
 	return 0;
 }
@@ -190,14 +190,16 @@ const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
 	psize /= 4;
 
 	onesize = na + ns;
-	for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
-		if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
+	for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) {
+		u32 val = be32_to_cpu(prop[0]);
+		if ((val & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
 			if (size)
 				*size = of_read_number(prop + na, ns);
 			if (flags)
 				*flags = bus->get_flags(prop);
 			return prop;
 		}
+	}
 	return NULL;
 }
 EXPORT_SYMBOL(of_get_pci_address);

  parent reply	other threads:[~2010-06-08 14:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100608140917.25879.67745.stgit@angua>
2010-06-08 14:09 ` [PATCH 1/5] of/address: merge of_iomap() Grant Likely
2010-06-10  6:40   ` Benjamin Herrenschmidt
2010-06-08 14:10 ` [PATCH 2/5] of/address: merge of_address_to_resource() Grant Likely
2010-06-10  6:41   ` Benjamin Herrenschmidt
2010-06-08 14:10 ` [PATCH 3/5] of/address: Merge all of the bus translation code Grant Likely
2010-06-10  6:43   ` Benjamin Herrenschmidt
2010-06-10 14:26     ` Grant Likely
2010-06-21 21:06       ` Grant Likely
2010-06-21 23:16         ` Benjamin Herrenschmidt
2010-06-08 14:10 ` Grant Likely [this message]
2010-06-10  6:43   ` [PATCH 4/5] of/address: little-endian fixes Benjamin Herrenschmidt
2010-06-08 14:10 ` [PATCH 5/5] of/address: restrict 'no-ranges' kludge to powerpc Grant Likely
2010-06-08 14:10   ` Grant Likely
2010-06-10  6:44   ` Benjamin Herrenschmidt
2010-06-10  6:44     ` Benjamin Herrenschmidt
2010-06-10 14:28     ` Grant Likely
2010-06-10 14:28       ` Grant Likely
2010-06-11  1:12       ` Benjamin Herrenschmidt
2010-06-11  1:12         ` Benjamin Herrenschmidt
2010-06-15 16:23     ` Segher Boessenkool
2010-06-15 16:23       ` Segher Boessenkool
2010-06-16  0:33       ` Benjamin Herrenschmidt
2010-06-16  0:33         ` Benjamin Herrenschmidt
2010-06-08 14:12 ` [PATCH 0/5] Merge common address translation code (ppc & mb) Grant Likely

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=20100608141013.25879.34892.stgit@angua \
    --to=grant.likely@secretlab.ca \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=microblaze-uclinux@itee.uq.edu.au \
    --cc=monstr@monstr.eu \
    --cc=sfr@canb.auug.org.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.