From: Florian Fainelli <ffainelli@freebox.fr>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@linux-mips.org, Maxime Bizon <mbizon@freebox.fr>,
ralf@linux-mips.org
Subject: Re: [PATCH 2/2] MIPS: add readl/write_be
Date: Tue, 15 Dec 2009 01:44:03 +0100 [thread overview]
Message-ID: <200912150144.04051.ffainelli@freebox.fr> (raw)
In-Reply-To: <10f740e80912141105kcccb4e9y68cf47b35bb7a648@mail.gmail.com>
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@freebox.fr> 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@freebox.fr>
> > 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@freebox.fr>
> > ---
> > 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@freebox.fr>
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@freebox.fr>
---
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
*/
--
next prev parent reply other threads:[~2009-12-15 0:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-12 16:57 [PATCH 2/2] MIPS: add readl/write_be Florian Fainelli
2009-12-12 19:31 ` Thomas Bogendoerfer
2009-12-14 17:02 ` Florian Fainelli
2009-12-14 19:05 ` Geert Uytterhoeven
2009-12-15 0:44 ` Florian Fainelli [this message]
2009-12-15 8:25 ` Ralf Baechle
2009-12-16 10:29 ` Florian Fainelli
2010-01-13 13:48 ` Ralf Baechle
2009-12-15 12:03 ` Sergei Shtylyov
2009-12-14 16:40 ` David Daney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200912150144.04051.ffainelli@freebox.fr \
--to=ffainelli@freebox.fr \
--cc=geert@linux-m68k.org \
--cc=linux-mips@linux-mips.org \
--cc=mbizon@freebox.fr \
--cc=ralf@linux-mips.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).