* [PATCH] Cosmetic: fix endianness convertions in read[wlq]().
@ 2012-05-05 21:36 Krzysztof Halasa
2012-05-06 17:35 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Halasa @ 2012-05-05 21:36 UTC (permalink / raw)
To: barebox
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 3f0f5a2..8480acf 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cosmetic: fix endianness convertions in read[wlq]().
2012-05-05 21:36 [PATCH] Cosmetic: fix endianness convertions in read[wlq]() Krzysztof Halasa
@ 2012-05-06 17:35 ` Sascha Hauer
2012-05-06 20:08 ` Krzysztof Halasa
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2012-05-06 17:35 UTC (permalink / raw)
To: Krzysztof Halasa; +Cc: barebox
On Sat, May 05, 2012 at 11:36:40PM +0200, Krzysztof Halasa wrote:
> Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
>
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 3f0f5a2..8480acf 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -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
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cosmetic: fix endianness convertions in read[wlq]().
2012-05-06 17:35 ` Sascha Hauer
@ 2012-05-06 20:08 ` Krzysztof Halasa
0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Halasa @ 2012-05-06 20:08 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Sascha Hauer <s.hauer@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-06 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-05 21:36 [PATCH] Cosmetic: fix endianness convertions in read[wlq]() Krzysztof Halasa
2012-05-06 17:35 ` Sascha Hauer
2012-05-06 20:08 ` Krzysztof Halasa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox