From: Randy Dunlap <randy.dunlap@Oracle.com>
To: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Johannes Berg <johannes@sipsolutions.net>
Subject: Re: [PATCH] kernel: add bit rotation helpers for 16 and 8 bit
Date: Tue, 18 Mar 2008 13:32:28 -0700 [thread overview]
Message-ID: <47E026DC.6020603@oracle.com> (raw)
In-Reply-To: <1205871841.17607.10.camel@brick>
Harvey Harrison wrote:
> Will replace open-coded variants elsewhere. Done in the same
> style as the 32-bit versions.
>
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> ---
> Andrew, these will be used to replace some open-coded variants in the
> mac80211 code, there are currently no users so it can go in with little
> risk.
>
> Randy, CC'd in case I screwed up the kerneldoc.
Looks good.
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
> include/linux/bitops.h | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 69c1edb..40d5473 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -65,6 +65,46 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
> return (word >> shift) | (word << (32 - shift));
> }
>
> +/**
> + * rol16 - rotate a 16-bit value left
> + * @word: value to rotate
> + * @shift: bits to roll
> + */
> +static inline __u16 rol16(__u16 word, unsigned int shift)
> +{
> + return (word << shift) | (word >> (16 - shift));
> +}
> +
> +/**
> + * ror16 - rotate a 16-bit value right
> + * @word: value to rotate
> + * @shift: bits to roll
> + */
> +static inline __u16 ror16(__u16 word, unsigned int shift)
> +{
> + return (word >> shift) | (word << (16 - shift));
> +}
> +
> +/**
> + * rol8 - rotate an 8-bit value left
> + * @word: value to rotate
> + * @shift: bits to roll
> + */
> +static inline __u8 rol8(__u8 word, unsigned int shift)
> +{
> + return (word << shift) | (word >> (8 - shift));
> +}
> +
> +/**
> + * ror8 - rotate an 8-bit value right
> + * @word: value to rotate
> + * @shift: bits to roll
> + */
> +static inline __u8 ror8(__u8 word, unsigned int shift)
> +{
> + return (word >> shift) | (word << (8 - shift));
> +}
> +
> static inline unsigned fls_long(unsigned long l)
> {
> if (sizeof(l) == 4)
--
~Randy
prev parent reply other threads:[~2008-03-20 11:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-18 20:24 [PATCH] kernel: add bit rotation helpers for 16 and 8 bit Harvey Harrison
2008-03-18 20:32 ` Randy Dunlap [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=47E026DC.6020603@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=harvey.harrison@gmail.com \
--cc=johannes@sipsolutions.net \
--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;
as well as URLs for NNTP newsgroup(s).