From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@ZenIV.linux.org.uk>,
linux-arch <linux-arch@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Matthew Wilcox <matthew@wil.cx>,
linux-scsi <linux-scsi@vger.kernel.org>,
Boaz Harrosh <bharrosh@panasas.com>
Subject: Re: [RFC] Normalizing byteorder/unaligned access API
Date: Wed, 8 Oct 2008 09:13:09 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.64.0810080908480.19202@anakin> (raw)
In-Reply-To: <1223416391.8195.22.camel@brick>
On Tue, 7 Oct 2008, Harvey Harrison wrote:
> [related question regarding the SCSI-private endian helper needs at the end]
>
> Currently on the read side, we have (le16 as an example endianness)
>
> le16_to_cpup(__le16 *)
> get_unaligned_le16(void *)
>
> And on the write side:
>
> *(__le16)ptr = cpu_to_le16(u16)
> put_unaligned_le16(u16, void *);
>
> On the read side, Al said he would have preferred the unaligned version
> take the same types as the aligned, rather than void *. AKPM didn't think
As I said before, me too (take the same types as the aligned). I like to
rely on sparse for:
struct {
...
__le32 x;
...
} s __attribute__ ((packed));
get_unaligned_le16(&s.x);
> the use of get_ was that great as get/put generally implies some kind of reference
> taking in the kernel.
OK.
> As the le16_to_cpup has been around for so long and is more recognizable, let's
> make it the same for the unaligned case and typesafe:
>
> le16_to_cpup(__le16 *)
> unaligned_le16_to_cpup(__le16 *)
I always hated that naming...
> On the write side, the above get/put and type issues are still there, in addition AKPM felt
> that the ordering of the put_unaligned parameters was opposite what was intuitive and that
> the pointer should come first.
>
> In this case, as there is currently no aligned helper (other than in some drivers defining macros)
> define the api thusly:
>
> Aligned:
> write_le16(__le16 *ptr, u16 val)
>
> Unaligned:
> unaligned_write_le16(__le16 *ptr, u16 val)
Does it write to MMIO I/O space? No? Then please don't use write (like
in writeb()).
What about load_{unaligned_,}le16() and store_{unaligned_,}le16()?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
next prev parent reply other threads:[~2008-10-08 7:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-07 21:53 Harvey Harrison
2008-10-07 22:12 ` James Bottomley
2008-10-07 22:39 ` Harvey Harrison
2008-10-07 23:33 ` Matthew Wilcox
2008-10-07 23:39 ` Harvey Harrison
2008-10-08 7:15 ` Geert Uytterhoeven
2008-10-07 23:28 ` Matthew Wilcox
2008-10-07 23:35 ` Harvey Harrison
2008-10-07 23:55 ` Matthew Wilcox
2008-10-08 0:02 ` Harvey Harrison
2008-10-08 7:31 ` Marcel Holtmann
2008-10-08 7:13 ` Geert Uytterhoeven [this message]
2008-10-08 7:34 ` Harvey Harrison
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=Pine.LNX.4.64.0810080908480.19202@anakin \
--to=geert@linux-m68k.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=bharrosh@panasas.com \
--cc=harvey.harrison@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=viro@ZenIV.linux.org.uk \
/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
all inboxes | Powered by JetHome®