summaryrefslogtreecommitdiffstats
path: root/drivers/staging/ks7010/michael_mic.c
diff options
context:
space:
mode:
authorSergio Paracuellos <sergio.paracuellos@gmail.com>2018-03-11 12:11:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-03-14 12:57:06 +0100
commit8b6f053790d94cceb323c2754fcd69c1286778b8 (patch)
tree03ec04eb90879603a8c20d9a455a4789f955ce04 /drivers/staging/ks7010/michael_mic.c
parentae91ce5db517626168a970806e650122a9b6d9f7 (diff)
staging: ks7010: replace custom rotation operations in favour of the kernel ones
This patch replaces custom ROR32 and ROL32 macros for the ones included in bitops header of the linux kernel. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ks7010/michael_mic.c')
-rw-r--r--drivers/staging/ks7010/michael_mic.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 80497ef5b1aa..1df4366fdb71 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -11,11 +11,9 @@
#include <linux/types.h>
#include <linux/string.h>
+#include <linux/bitops.h>
#include "michael_mic.h"
-// Rotation functions on 32 bit values
-#define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1)))
-#define ROR32(A, n) ROL32((A), 32 - (n))
// Convert from Byte[] to UInt32 in a portable way
#define getUInt32(A, B) ((uint32_t)(A[B + 0] << 0) \
+ (A[B + 1] << 8) + (A[B + 2] << 16) + (A[B + 3] << 24))
@@ -50,13 +48,13 @@ void MichaelInitializeFunction(struct michael_mic_t *Mic, uint8_t *key)
#define MichaelBlockFunction(L, R) \
do { \
- R ^= ROL32(L, 17); \
+ R ^= rol32(L, 17); \
L += R; \
R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); \
L += R; \
- R ^= ROL32(L, 3); \
+ R ^= rol32(L, 3); \
L += R; \
- R ^= ROR32(L, 2); \
+ R ^= ror32(L, 2); \
L += R; \
} while (0)