From: "Patryk Gawroński" <gawronski1.6@gmail.com>
To: gregkh@linuxfoundation.org
Cc: "Patryk Gawroński" <gawronski1.6@gmail.com>,
"Dan Carpenter" <error27@gmail.com>,
"Ethan Tidmore" <ethantidmore06@gmail.com>,
"Lin YuChen" <starpt.official@gmail.com>,
"Maksym Pikhotskyi" <mpikhotskyi@gmail.com>,
"Michael Straube" <straube.linux@gmail.com>,
"Sameeksha Sankpal" <sameekshasankpal@gmail.com>,
"Artur Stupa" <arthur.stupa@gmail.com>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: rtl8723bs: Replace custom RotR1 macro with ror16
Date: Wed, 22 Jul 2026 23:53:25 +0200 [thread overview]
Message-ID: <20260722215327.62791-1-gawronski1.6@gmail.com> (raw)
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
reply other threads:[~2026-07-22 21:53 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=20260722215327.62791-1-gawronski1.6@gmail.com \
--to=gawronski1.6@gmail.com \
--cc=arthur.stupa@gmail.com \
--cc=error27@gmail.com \
--cc=ethantidmore06@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mpikhotskyi@gmail.com \
--cc=sameekshasankpal@gmail.com \
--cc=starpt.official@gmail.com \
--cc=straube.linux@gmail.com \
/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
Powered by JetHome