MIPS: add readl/write_be
PATCH 2/2 MIPS: add readl/write_be
MIPS currently lacks the readl_be and writel_be accessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
---
arch/mips/include/asm/io.h +3 -0
@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) __raw_readl((__force unsigned *)addr) +#define writel_be (val, addr) __raw_writel(val, (__force unsigned *)addr) +/* * Some code tests for these symbols */
Thomas Bogendoerfer
maintainerarch/mips/include/asm/io.h __BUILDIO(q, u64) · line 451
Quoted 2 lines · Florian Fainelli
arch/mips/include/asm/io.h +2
-0+#define readl_be (addr) __raw_readl((__force unsigned *)addr) +#define writel_be (val, addr) __raw_writel(val, (__force unsigned *)addr)
looks broken for little endian machines. __raw_XXX doesn't do any swapping, so IMHO the correct thing would be to use be32_to_cpu/cpu_to_be32.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a good idea. [ RFC1925, 2.3 ]
Hello Thomas,
Quoted 7 lines · On Saturday 12 December 2009 20:31:14 Thomas Bogendoerfer wrote:
Quoted 3 lines · Florian Fainelli
(quoted diff) +2
-0+#define readl_be(addr) __raw_readl((__force unsigned *)addr) +#define writel_be(val, addr) __raw_writel(val, (__force unsigned*)addr)
looks broken for little endian machines.
__raw_XXXdoesn't do any swapping, so IMHO the correct thing would be to use be32_to_cpu/cpu_to_be32.
Yeah, I missed that point. Please find below version 2 of the patch which also addresses David's comment. --
From: Florian Fainelli <[email protected]>
Subject: [PATCH v2] MIPS: add readl_be/writel_be
MIPS currently lacks the readl_be and writel_be accessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
Changes from v1:
- make it work on little-endian machines
- protect macros arguments with parenthesis
---
arch/mips/include/asm/io.h +3 -0
@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) cpu_to_be32(__raw_readl((__force unsigned *)(addr))) +#define writel_be (val, addr) __raw_writel(be32_to_cpu((val)), (__force unsigned *)(addr)) +/* * Some code tests for these symbols */
Quoted 30 lines · Florian Fainelli
Quoted 7 lines · On Saturday 12 December 2009 20:31:14 Thomas Bogendoerfer wrote:
Quoted 3 lines · Florian Fainelli
(quoted diff) +2
-0+#define readl_be(addr) __raw_readl((__force unsigned *)addr) +#define writel_be(val, addr) __raw_writel(val, (__force unsigned*)addr)
looks broken for little endian machines.
__raw_XXXdoesn't do any swapping, so IMHO the correct thing would be to use be32_to_cpu/cpu_to_be32.Yeah, I missed that point. Please find below version 2 of the patch which also addresses David's comment. --
From: Florian Fainelli <[email protected]>
Subject: [PATCH v2] MIPS: add readl_be/writel_beMIPS currently lacks the
readl_beandwritel_beaccessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.Changes from v1:
- make it work on little-endian machines
- protect macros arguments with parenthesisSigned-off-by Florian Fainelli <[email protected]>---
arch/mips/include/asm/io.h +0
-0
arch/mips/include/asm/io.h __BUILDIO(q, u64) · line 451
Quoted 5 lines
arch/mips/include/asm/io.h +2
-0@@ -447,6 +447,9 @@ __BUILDIO(q, u64) #define readl_relaxed readl #define readq_relaxed readq +#define readl_be (addr) cpu_to_be32(__raw_readl((__force unsigned *)(addr))) +#define writel_be (val, addr) __raw_writel(be32_to_cpu((val)), (__force unsigned *)(addr))
Shouldn't it be the other way around (cpu <-> be32), i.e.
#define readl_be(addr) be32_to_cpu(__raw_readl((__force unsigned *)(addr))) #define writel_be(val, addr) __raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
? I know it'll work both ways, though...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 41 lines · Geert Uytterhoeven
Quoted 31 lines · Florian Fainelli
Quoted 8 lines · On Saturday 12 December 2009 20:31:14 Thomas Bogendoerfer wrote:
Quoted 3 lines · Florian Fainelli
+#define
readl_be(addr)__raw_readl((__force
unsigned *)addr) +#definewritel_be(val, addr)__raw_writel(val, (__force unsigned *)addr)looks broken for little endian machines.
__raw_XXXdoesn't do any swapping, so IMHO the correct thing would be to use be32_to_cpu/cpu_to_be32.Yeah, I missed that point. Please find below version 2 of the patch which also addresses David's comment. --
From: Florian Fainelli <[email protected]>
Subject: [PATCH v2] MIPS: add readl_be/writel_beMIPS currently lacks the
readl_beandwritel_beaccessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.Changes from v1:
- make it work on little-endian machines
- protect macros arguments with parenthesisSigned-off-by Florian Fainelli <[email protected]>---
arch/mips/include/asm/io.h +0
-0arch/mips/include/asm/io.h __BUILDIO(q, u64) · line 452
Quoted 6 lines
arch/mips/include/asm/io.h +1
-0@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) cpu_to_be32(__raw_readl((__force unsigned *)(addr))) +#define writel_be(val, addr) __raw_writel(be32_to_cpu((val)), (__force unsigned *)(addr))Shouldn't it be the other way around (cpu <-> be32), i.e.
Quoted 4 lines
#define
readl_be(addr)be32_to_cpu(__raw_readl((__force unsigned *)(addr)))#definewritel_be(val, addr)__raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
It should, I inverted the semantics. I should think twice before sending stuff :) --
From: Florian Fainelli <[email protected]>
Subject: [PATCH v3] MIPS: add readl/write_be accessors
MIPS currently lacks the readl_be and writel_be accessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
Changes from v2:
- fixed the be/cpu endianness inversion
Changes from v1:
- make it work on little-endian machines
- protect macros arguments with parenthesis
---
arch/mips/include/asm/io.h +3 -0
@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) be32_to_cpu(__raw_readl((__force unsigned *)(addr))) +#define writel_be (val, addr) __raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr)) +/* * Some code tests for these symbols */
Quoted 1 line · Florian Fainelli
It should, I inverted the semantics. I should think twice before sending stuff :)
That should include Documentation/SubmittingPatches :-)
Ralf
From: Florian Fainelli <[email protected]>
Subject: [PATCH v3] MIPS: add readl/write_be accessors
MIPS currently lacks the readl_be and writel_be accessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
---
arch/mips/include/asm/io.h +3 -0
@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) be32_to_cpu(__raw_readl((__force unsigned *)(addr))) +#define writel_be (val, addr) __raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr)) +/* * Some code tests for these symbols */
Ralf Baechle
AppliedQuoted 7 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
Subject: [PATCH v3] MIPS: add readl/write_be accessorsMIPS currently lacks the
readl_beandwritel_beaccessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
Queued; I've added the b, w and q variants to make the patch feature complete even though there are probably no users atm.
Ralf
Hello.
Quoted 8 lines · Florian Fainelli
From: Florian Fainelli <[email protected]>
Subject: [PATCH v3] MIPS: add readl/write_be accessorsMIPS currently lacks the
readl_beandwritel_beaccessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.
Quoted 7 lines
Changes from v2:
- fixed the be/cpu endianness inversionChanges from v1:
- make it work on little-endian machines
- protect macros arguments with parenthesis
You should have put the description of changes under --- tearline,
not in the patch description itself.
Quoted 2 lines
Signed-off-by Florian Fainelli <[email protected]>---
WBR, Sergei
Quoted 12 lines · Florian Fainelli
MIPS currently lacks the
readl_beandwritel_beaccessors which are required by BCM63xx for OHCI and EHCI support. Let's define them globally for MIPS. This also fixes the compilation of the bcm63xx defconfig against USB.Signed-off-by Florian Fainelli <[email protected]>---
arch/mips/include/asm/io.h +0
-0
arch/mips/include/asm/io.h __BUILDIO(q, u64) · line 452
Quoted 6 lines
arch/mips/include/asm/io.h +3
-0@@ -447,6 +447,9 @@ __BUILDIO(q, u64)#define readl_relaxed readl#define readq_relaxed readq +#define readl_be (addr) __raw_readl((__force unsigned *)addr) +#define writel_be (val, addr) __raw_writel(val, (__force unsigned *)addr) +
Without addressing the need for the patch, as a technical matter, the macro parameters should probably be protected by parenthesis. I.E.:
#define readl_be(addr) __raw_readl((__force unsigned *)(addr))
#define writel_be(val, addr) __raw_writel((val), (__force unsigned *)(addr))