Cosmetic: fix endianness convertions in read[wlq]().
PATCH 1/1 Cosmetic: fix endianness convertions in read[wlq]().
include/asm-generic/io.h +3 -3
@@ -35,8 +35,8 @@#endif #define readb __raw_readb -#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))#ifndef __raw_writeb#define __raw_writeb (v,a) (__chk_io_ptr(a), *(volatile unsigned char __force *)(a) = (v))
@@ -59,7 +59,7 @@ static inline u64 __raw_readq(const volatile void __iomem *addr) {return *(const volatile u64 __force *) addr; } -#define readq (addr) __le64_to_cpu(__raw_readq(addr)) +#define readq (addr) __cpu_to_le64(__raw_readq(addr))static inline void __raw_writeq (u64 b,volatile void __iomem *addr) {
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Krzysztof Halasa
Signed-off-by Krzysztof Hałasa <[email protected]>include/asm-generic/io.h +0
-0
include/asm-generic/io.h line 39
Quoted 7 lines
include/asm-generic/io.h +2
-2@@ -35,8 +35,8 @@#endif #define readb __raw_readb -#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)
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Sascha Hauer
include/asm-generic/io.h line 39
Quoted 4 lines
include/asm-generic/io.h +2
-2-#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.
Signature · 6 lines
Krzysztof Halasa _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox