aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/address.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-06-08 09:48:11 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-05 18:14:27 -0400
commit154063a9c03d31228b6f9366d2ffc2b7c4961698 (patch)
tree10b33509876ef5b4a59f22ee88586ab2dfbbd999 /drivers/of/address.c
parentdbbdee94734bf6f1db7af42008a53655e77cab8f (diff)
of/address: little-endian fixes
Fix some endian issues in the OF address translation code. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Michal Simek <monstr@monstr.eu> CC: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'drivers/of/address.c')
-rw-r--r--drivers/of/address.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 2a905d560c1c..0b04137f04f7 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)
22{ 22{
23 printk(KERN_DEBUG "%s", s); 23 printk(KERN_DEBUG "%s", s);
24 while (na--) 24 while (na--)
25 printk(" %08x", *(addr++)); 25 printk(" %08x", be32_to_cpu(*(addr++)));
26 printk("\n"); 26 printk("\n");
27} 27}
28#else 28#else
@@ -79,8 +79,8 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na)
79 memset(addr, 0, na * 4); 79 memset(addr, 0, na * 4);
80 a += offset; 80 a += offset;
81 if (na > 1) 81 if (na > 1)
82 addr[na - 2] = a >> 32; 82 addr[na - 2] = cpu_to_be32(a >> 32);
83 addr[na - 1] = a & 0xffffffffu; 83 addr[na - 1] = cpu_to_be32(a & 0xffffffffu);
84 84
85 return 0; 85 return 0;
86} 86}
@@ -190,14 +190,16 @@ const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
190 psize /= 4; 190 psize /= 4;
191 191
192 onesize = na + ns; 192 onesize = na + ns;
193 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) 193 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) {
194 if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) { 194 u32 val = be32_to_cpu(prop[0]);
195 if ((val & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
195 if (size) 196 if (size)
196 *size = of_read_number(prop + na, ns); 197 *size = of_read_number(prop + na, ns);
197 if (flags) 198 if (flags)
198 *flags = bus->get_flags(prop); 199 *flags = bus->get_flags(prop);
199 return prop; 200 return prop;
200 } 201 }
202 }
201 return NULL; 203 return NULL;
202} 204}
203EXPORT_SYMBOL(of_get_pci_address); 205EXPORT_SYMBOL(of_get_pci_address);