public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org, Boaz Harrosh <bharrosh@panasas.com>,
	Matthew Wilcox <matthew@wil.cx>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: get/put unaligned helpers
Date: Fri, 13 Feb 2009 14:07:02 -0800	[thread overview]
Message-ID: <1234562823.5521.21.camel@brick> (raw)
In-Reply-To: <20090211143521.GA18866@lst.de>

On Wed, 2009-02-11 at 15:35 +0100, Christoph Hellwig wrote:
> I just loked into using the new get/put unaligned helpers.  I must
> say that I'm really unhappy about the lack of typing there.  We did
> put all the sparse infrastructure in place to make sure we do have
> strong typechecking for LE/Be types, but using these helpers defeats
> that.
> 
> Can you please make these properly typed?

Christoph, here's a quick summary of comments on the unaligned access bits
I've previously submitted, please let me know if you have any additional ones.

Proposed API:

u16 load_le16_noalign(const __le16 *p)
u32 load_le32_noalign(const __le32 *p)
u64 load_le64_noalign(const __le64 *p)
u16 load_be16_noalign(const __be16 *p)
u32 load_be32_noalign(const __be32 *p)
u64 load_be64_noalign(const __be64 *p)

void store_le16_noalign(__le16 *p, u16 val)
void store_le32_noalign(__le32 *p, u32 val)
void store_le64_noalign(__le64 *p, u64 val)
void store_be16_noalign(__be16 *p, u16 val)
void store_be32_noalign(__be32 *p, u32 val)
void store_be64_noalign(__be64 *p, u64 val)

I'd also like to offer aligned versions like load_le16() store_le16()
to make it symmetric.  Then for arches that have no alignment constraints
the unaligned helpers would degrade to the aligned helpers.  load_le16()
already exists as le16_to_cpup, but store_le16 would be a new API.

Now, from discussions with the SCSI-folks, they really aren't interested in a
typesafe interface as most of the time they are reading/writing into a u8 buffer
at some offset.  It seems a lot of the other places currently in-kernel also
do the same.  So I'm tempted to keep offering a version wrapped around the
typesafe versions that takes a u8 *.

As they were not interested in doing the following:

load_be16_noalign((__be16 *)&buf[offset]);

Perhaps a wrapper could be provided:

load_be16_offset(u8 *buf, int offset)

Thoughts?

Harvey


      parent reply	other threads:[~2009-02-13 22:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-11 14:35 get/put unaligned helpers Christoph Hellwig
2009-02-11 15:48 ` Harvey Harrison
2009-02-12  8:50   ` Boaz Harrosh
2009-02-12 12:44     ` Maciej W. Rozycki
2009-02-12 12:55       ` Boaz Harrosh
2009-02-12 14:39         ` Maciej W. Rozycki
2009-02-12 18:43     ` Stefan Richter
2009-02-12 20:20     ` Harvey Harrison
2009-02-13 22:07 ` Harvey Harrison [this message]

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=1234562823.5521.21.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bharrosh@panasas.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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