From: Harvey Harrison <harvey.harrison@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Benc <jbenc@suse.cz>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH-mm 2/3] mac80211: michael.c use get/put_unaligned helpers
Date: Wed, 16 Apr 2008 11:29:31 -0700 [thread overview]
Message-ID: <1208370571.11920.108.camel@brick> (raw)
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
net/mac80211/michael.c | 31 ++++++++-----------------------
1 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/net/mac80211/michael.c b/net/mac80211/michael.c
index 36bb3bb..698d7b3 100644
--- a/net/mac80211/michael.c
+++ b/net/mac80211/michael.c
@@ -27,35 +27,20 @@ static void michael_block(u32 val, u32 *l, u32 *r)
*l += *r;
}
-static u32 michael_get16(u8 *data)
-{
- return le16_to_cpu(get_unaligned((__le16 *)data));
-}
-
-static u32 michael_get32(u8 *data)
-{
- return le32_to_cpu(get_unaligned((__le32 *)data));
-}
-
-static void michael_put32(u32 val, u8 *data)
-{
- put_unaligned(cpu_to_le32(val), (__le32 *)data);
-}
-
void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
u8 *data, size_t data_len, u8 *mic)
{
u32 l, r, val;
size_t block, blocks, left;
- l = michael_get32(key);
- r = michael_get32(key + 4);
+ l = get_unaligned_le32(key);
+ r = get_unaligned_le32(key + 4);
/* A pseudo header (DA, SA, Priority, 0, 0, 0) is used in Michael MIC
* calculation, but it is _not_ transmitted */
- michael_block(michael_get32(da), &l, &r);
- michael_block(michael_get16(da) | (michael_get16(sa) << 16), &l, &r);
- michael_block(michael_get32(&sa[2]), &l, &r);
+ michael_block(get_unaligned_le32(da), &l, &r);
+ michael_block(get_unaligned_le16(da) | (get_unaligned_le16(sa) << 16), &l, &r);
+ michael_block(get_unaligned_le32(sa + 2), &l, &r);
michael_block(priority, &l, &r);
/* Real data */
@@ -63,7 +48,7 @@ void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
left = data_len % 4;
for (block = 0; block < blocks; block++)
- michael_block(michael_get32(&data[block * 4]), &l, &r);
+ michael_block(get_unaligned_le32(data + (block * 4)), &l, &r);
/* Partial block of 0..3 bytes and padding: 0x5a + 4..7 zeros to make
* total length a multiple of 4. */
@@ -76,6 +61,6 @@ void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
michael_block(val, &l, &r);
michael_block(0, &l, &r);
- michael_put32(l, mic);
- michael_put32(r, mic + 4);
+ put_unaligned_le32(l, mic);
+ put_unaligned_le32(r, mic + 4);
}
--
1.5.5.144.g3e42
reply other threads:[~2008-04-16 18:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1208370571.11920.108.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jbenc@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.