Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

staging: rtl8723bs: use unaligned access macros in rtw_security.c

The driver defines custom functions secmicgetuint32() and
secmicputuint32() to handle little-endian byte-to-integer conversion.
This is redundant as the kernel provides optimized standard macros for
this purpose in <linux/unaligned.h>.

Replace the custom implementations with get_unaligned_le32() and
put_unaligned_le32() and delete the now-unused local functions.

Signed-off-by: Archit Anant <architanant5@gmail.com>
Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com>
Link: https://patch.msgid.link/20260130075113.34666-1-architanant5@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Archit Anant and committed by
Greg Kroah-Hartman
17d2ff40 02df7c63

+5 -27
+5 -27
drivers/staging/rtl8723bs/core/rtw_security.c
··· 5 5 * 6 6 ******************************************************************************/ 7 7 #include <linux/crc32.h> 8 + #include <linux/unaligned.h> 8 9 #include <drv_types.h> 9 10 #include <crypto/aes.h> 10 11 #include <crypto/utils.h> ··· 129 128 130 129 /* 3 =====TKIP related ===== */ 131 130 132 - static u32 secmicgetuint32(u8 *p) 133 - /* Convert from Byte[] to Us3232 in a portable way */ 134 - { 135 - s32 i; 136 - u32 res = 0; 137 - 138 - for (i = 0; i < 4; i++) 139 - res |= ((u32)(*p++)) << (8 * i); 140 - 141 - return res; 142 - } 143 - 144 - static void secmicputuint32(u8 *p, u32 val) 145 - /* Convert from Us3232 to Byte[] in a portable way */ 146 - { 147 - long i; 148 - 149 - for (i = 0; i < 4; i++) { 150 - *p++ = (u8) (val & 0xff); 151 - val >>= 8; 152 - } 153 - } 154 - 155 131 static void secmicclear(struct mic_data *pmicdata) 156 132 { 157 133 /* Reset the state to the empty message. */ ··· 141 163 void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) 142 164 { 143 165 /* Set the key */ 144 - pmicdata->K0 = secmicgetuint32(key); 145 - pmicdata->K1 = secmicgetuint32(key + 4); 166 + pmicdata->K0 = get_unaligned_le32(key); 167 + pmicdata->K1 = get_unaligned_le32(key + 4); 146 168 /* and reset the message */ 147 169 secmicclear(pmicdata); 148 170 } ··· 190 212 while (pmicdata->nBytesInM != 0) 191 213 rtw_secmicappendbyte(pmicdata, 0); 192 214 /* The appendByte function has already computed the result. */ 193 - secmicputuint32(dst, pmicdata->L); 194 - secmicputuint32(dst + 4, pmicdata->R); 215 + put_unaligned_le32(pmicdata->L, dst); 216 + put_unaligned_le32(pmicdata->R, dst + 4); 195 217 /* Reset to the empty message. */ 196 218 secmicclear(pmicdata); 197 219 }