[PATCH] Cosmetic: fix endianness convertions in read[wlq]().

Krzysztof Halasa khc at pm.waw.pl
Sun May 6 16:08:48 EDT 2012


Sascha Hauer <s.hauer at pengutronix.de> writes:

>> -#define readw(addr) __le16_to_cpu(__raw_readw(addr))
>> -#define readl(addr) __le32_to_cpu(__raw_readl(addr))
>> +#define readw(addr) __cpu_to_le16(__raw_readw(addr))
>> +#define readl(addr) __cpu_to_le32(__raw_readl(addr))
>
> This seems wrong. readw/l are supposed to do little endian reads and that
> is exactly what the code you remove does: It reads in cpu native
> endianess and interprets that as a little endian word which is then
> converted into cpu native endian word.
> (Also the code is copied from the kernel which makes me quite confident
> that it's correct)

Well... That's right. I forgot the PCI on ARM is set in order-preserving
mode. This means that while the peripherals (u32) are accessed simply
with __raw_readl(), on PCI bus __raw_readl() yields wrong-endian value
(le32 instead of u32). I wonder how it passes sparse.
-- 
Krzysztof Halasa



More information about the barebox mailing list