public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 01/21] lib: add byteorder helpers for the aligned case
Date: Fri, 23 May 2008 15:13:10 +0200	[thread overview]
Message-ID: <20080523131310.GC9245@ucw.cz> (raw)
In-Reply-To: <1211306721.5915.167.camel@brick>

On Tue 2008-05-20 11:05:21, Harvey Harrison wrote:
> Some users know the pointer they are writeing to are aligned,
> rather than doing *(__le16 *)ptr = cpu_to_le16(val) add helpers
> wrapping this up that have the same convention as put_unaligned_le/be.
> 
> Although the get_be/le versions duplicate the le16_to_cpup functionality
> add them anyway as it makes this a complete api and start work to
> eliminate {le|be}{16|32|64}_to_cpup uses (not many).
> 
> This makes the api look like:
> 
> get_unaligned_le16
> put_unaligned_le16
> 
> get_le16
> put_le16
> 
> With explicit alignment constraints.
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> ---
>  include/linux/byteorder/generic.h |   60 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 60 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
> index 0846e6b..1f0c07e 100644
> --- a/include/linux/byteorder/generic.h
> +++ b/include/linux/byteorder/generic.h
> @@ -119,6 +119,66 @@
>  #define cpu_to_be16s __cpu_to_be16s
>  #define be16_to_cpus __be16_to_cpus
>  
> +static inline u16 get_le16(void *ptr)
> +{
> +	return le16_to_cpu(*(__le16 *)ptr);
> +}
> +

Document the fact that void * passed in needs to be 16-bit aligned?

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2008-05-23 13:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 18:05 [PATCH 01/21] lib: add byteorder helpers for the aligned case Harvey Harrison
2008-05-23 13:13 ` Pavel Machek [this message]
2008-06-24 12:54   ` byteorder helpers and void * (was: Re: [PATCH 01/21] lib: add byteorder helpers for the aligned case) Geert Uytterhoeven
2008-06-25  2:35     ` Harvey Harrison
2008-06-25 11:20       ` Geert Uytterhoeven

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=20080523131310.GC9245@ucw.cz \
    --to=pavel@ucw.cz \
    --cc=akpm@linux-foundation.org \
    --cc=harvey.harrison@gmail.com \
    --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