Re: [PATCH 2/2] MIPS: add readl/write_be

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Geert,

Le lundi 14 décembre 2009 20:05:50, Geert Uytterhoeven a écrit :
> On Mon, Dec 14, 2009 at 18:02, Florian Fainelli <ffainelli@xxxxxxxxxx> wrote:
> > On Saturday 12 December 2009 20:31:14 Thomas Bogendoerfer wrote:
> >> On Sat, Dec 12, 2009 at 05:57:56PM +0100, Florian Fainelli wrote:
> >> > +#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.
> >
> > Yeah, I missed that point. Please find below version 2 of the patch which
> > also addresses David's comment. --
> > From: Florian Fainelli <ffainelli@xxxxxxxxxx>
> > 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
> >
> > Signed-off-by: Florian Fainelli <ffainelli@xxxxxxxxxx>
> > ---
> > diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
> > index 436878e..4a76d39 100644
> > --- a/arch/mips/include/asm/io.h
> > +++ b/arch/mips/include/asm/io.h
> > @@ -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))

It should, I inverted the semantics. I should think twice before sending stuff :)
--
From: Florian Fainelli <ffainelli@xxxxxxxxxx>
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

Signed-off-by: Florian Fainelli <ffainelli@xxxxxxxxxx>
---
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 436878e..65d7843 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -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
  */
-- 


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux