From: Arnd Bergmann <arnd@arndb.de>
To: "Lars-Peter Clausen" <lars@metafoo.de>
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic/io.h: Fix io{read,write}{16,32}be for big endian systems
Date: Tue, 18 Jan 2011 19:44:07 +0100 [thread overview]
Message-ID: <201101181944.07146.arnd@arndb.de> (raw)
In-Reply-To: <1295374261-19609-1-git-send-email-lars@metafoo.de>
On Tuesday 18 January 2011 19:11:01 Lars-Peter Clausen wrote:
> Currently io{read,write}{16,32} expand to
> *addr = cpu_to_leXX(cpu_to_beXX(val))
> and
> val = beXX_to_cpu(leXX_to_cpu(*addr))
>
> While it should rather be:
> *addr = cpu_to_be{16,32}(val)
> and
> val = be{16,32}_to_cpu(*addr)
>
> The current implementation works on litte-endian targets(where cpu_to_leXX is a
> noop), but breaks on on big-endian targets, this patch fixes it.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
The existing code looks broken on big-endian indeed, thanks
for the report!
However, you cannot use __raw_readl in general, because that
function knows nothing about the various kinds of I/O accesses
(potentially) handled by readl. Think of architectures where
readl is not a pointer dereference but something else.
The right solution is probably to use swab16/swab32 for the
big-endian functions. This also corrects the iowrite functions
which really should be using cpu_to_be32 instead of be32_to_cpu
(although they are always defined to be the same afaict.
Arnd
next prev parent reply other threads:[~2011-01-18 18:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-18 18:11 [PATCH] asm-generic/io.h: Fix io{read,write}{16,32}be for big endian systems Lars-Peter Clausen
2011-01-18 18:44 ` Arnd Bergmann [this message]
2011-01-18 19:01 ` Lars-Peter Clausen
2011-01-18 19:56 ` Arnd Bergmann
2011-01-18 20:54 ` Lars-Peter Clausen
2011-01-18 21:37 ` Arnd Bergmann
2011-01-18 22:22 ` Lars-Peter Clausen
2011-01-19 9:58 ` Arnd Bergmann
2011-01-19 12:28 ` Jonas Bonn
2011-01-19 14:47 ` Arnd Bergmann
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=201101181944.07146.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=lars@metafoo.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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