* [PATCH] staging: rtl8723bs: Replace custom RotR1 macro with ror16
@ 2026-07-22 21:53 Patryk Gawroński
0 siblings, 0 replies; only message in thread
From: Patryk Gawroński @ 2026-07-22 21:53 UTC (permalink / raw)
To: gregkh
Cc: Patryk Gawroński, Dan Carpenter, Ethan Tidmore, Lin YuChen,
Maksym Pikhotskyi, Michael Straube, Sameeksha Sankpal,
Artur Stupa, linux-staging, linux-kernel
The custom RotR1 macro reuses its argument, which throws a checkpatch
warning and can lead to unexpected side-effects if called with an
expression that has side-effects.
Remove the custom macro and replace its usages with the standard
kernel ror16() function from <linux/bitops.h> to clean up the code.
Signed-off-by: Patryk Gawroński <gawronski1.6@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 29e2a5a771dd..2217cffac5f2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -6,6 +6,7 @@
******************************************************************************/
#include <linux/crc32.h>
#include <linux/unaligned.h>
+#include <linux/bitops.h>
#include <drv_types.h>
#include <crypto/aes.h>
#include <crypto/utils.h>
@@ -225,7 +226,6 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod
}
/* macros for extraction/creation of unsigned char/unsigned short values */
-#define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15))
#define Lo8(v16) ((u8)((v16) & 0x00FF))
#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF))
#define Lo16(v32) ((u16)((v32) & 0xFFFF))
@@ -392,12 +392,12 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */
/* Final sweep: bijective, "linear". Rotates kill LSB correlations */
- PPK[0] += RotR1(PPK[5] ^ TK16(6));
- PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */
- PPK[2] += RotR1(PPK[1]);
- PPK[3] += RotR1(PPK[2]);
- PPK[4] += RotR1(PPK[3]);
- PPK[5] += RotR1(PPK[4]);
+ PPK[0] += ror16(PPK[5] ^ TK16(6), 1);
+ PPK[1] += ror16(PPK[0] ^ TK16(7), 1); /* Use all of TK[] in Phase2 */
+ PPK[2] += ror16(PPK[1], 1);
+ PPK[3] += ror16(PPK[2], 1);
+ PPK[4] += ror16(PPK[3], 1);
+ PPK[5] += ror16(PPK[4], 1);
/* Note: At this point, for a given key TK[0..15], the 96-bit output */
/* value PPK[0..5] is guaranteed to be unique, as a function */
/* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-22 21:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22 21:53 [PATCH] staging: rtl8723bs: Replace custom RotR1 macro with ror16 Patryk Gawroński
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox