staging: rtl8723bs: macro fixes in basic_types.h
cover staging: rtl8723bs: macro fixes in basic_types.h
This series addresses several issues in the basic_types.h header of the rtl8723bs driver.
The first patch fixes a latent logic bug in a 4-byte write macro. The second patch improves macro safety by adding parentheses. The remaining patches clean up coding style issues, including unnecessary do-while loops and redundant blank lines.
Mashiro Chen (4):
staging: rtl8723bs: fix logic bug in WRITEEF4BYTE macro
staging: rtl8723bs: wrap complex macros with parentheses
staging: rtl8723bs: remove unnecessary do-while for macros
staging: rtl8723bs: remove redundant blank lines in basic_types.h
.../staging/rtl8723bs/include/basic_types.h | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/4 staging: rtl8723bs: fix logic bug in WRITEEF4BYTE macro
The WRITEEF4BYTE macro incorrectly used EF2BYTE for 4-byte memory writes. Fix it to use EF4BYTE instead.
--- drivers/staging/rtl8723bs/include/basic_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/basic_types.h +1 -1
@@ -64,7 +64,7 @@#define WRITEEF4BYTE (_ptr, _val) \ do { \ - (*((u32 *)(_ptr))) = EF2BYTE(_val); \ + (*((u32 *)(_ptr))) = EF4BYTE(_val); \ } while (0)/*
Signature · 1 line
2.53.0
Re: [PATCH 1/4] staging: rtl8723bs: fix logic bug in WRITEEF4BYTE macro
Quoted 13 lines · Mashiro Chen
The WRITEEF4BYTE macro incorrectly used EF2BYTE for 4-byte memory writes. Fix it to use EF4BYTE instead.
Signed-off-by Mashiro Chen <[email protected]>--- drivers/staging/rtl8723bs/include/basic_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8723bs/include/basic_types.h +0
-0
drivers/staging/rtl8723bs/include/basic_types.h line 65
Quoted 2 lines
drivers/staging/rtl8723bs/include/basic_types.h +0
-0@@ -64,7 +64,7 @@#define WRITEEF4BYTE (_ptr, _val) \
This macro is never used so just delete it instead.
regards,
dan carpenter
Quoted 9 lines
drivers/staging/rtl8723bs/include/basic_types.h +1
-1do { \ - (*((u32 *)(_ptr))) =EF2BYTE (_val); \ + (*((u32 *)(_ptr))) =EF4BYTE (_val); \ }while (0 )/* Signature · 1 line
2.53.0
Re: [PATCH 1/4] staging: rtl8723bs: fix logic bug in WRITEEF4BYTE macro
Hi Dan,
Thank you for the feedback. After further investigation, WRITEEF2BYTE, WRITEEF1BYTE, READEF4BYTE, READEF2BYTE and READEF1BYTE are also unused. I will delete all of them in v2.
Thanks,
Mashiro Chen
PATCH 2/4 staging: rtl8723bs: wrap complex macros with parentheses
In reply to Mashiro ChenFix "COMPLEX_MACRO" errors reported by checkpatch.pl by wrapping macro values in parentheses to ensure correct operator precedence.
--- drivers/staging/rtl8723bs/include/basic_types.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/include/basic_types.h +6 -6
@@ -154,25 +154,25 @@* Set subfield of little-endian 4-byte value to specified value. */ #define SET_BITS_TO_LE_4BYTE (__pstart, __bitoffset, __bitlen, __val) \ - *((u32 *)(__pstart)) = \ + (*((u32 *)(__pstart)) = \ ( \ LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ - ) + ))#define SET_BITS_TO_LE_2BYTE (__pstart, __bitoffset, __bitlen, __val) \ - *((u16 *)(__pstart)) = \ + (*((u16 *)(__pstart)) = \ ( \ LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ - ) + ))#define SET_BITS_TO_LE_1BYTE (__pstart, __bitoffset, __bitlen, __val) \ - *((u8 *)(__pstart)) = EF1BYTE \ + (*((u8 *)(__pstart)) = EF1BYTE \ ( \ LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ - ) + ))#define LE_BITS_CLEARED_TO_1BYTE_8BIT (__pStart, __BitOffset, __BitLen) \ (\
Signature · 1 line
2.53.0
PATCH 3/4 staging: rtl8723bs: remove unnecessary do-while for macros
In reply to Mashiro ChenRemove unnecessary do-while loops and trailing semicolons for single statement macros to comply with Linux kernel coding style.
--- drivers/staging/rtl8723bs/include/basic_types.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/staging/rtl8723bs/include/basic_types.h +4 -9
@@ -53,19 +53,14 @@/* Write data to memory */ #define WRITEEF1BYTE (_ptr, _val) \ - do { \ - (*((u8 *)(_ptr))) = EF1BYTE(_val); \ - } while (0) + ((*((u8 *)(_ptr))) = EF1BYTE(_val)) +/* Write le data to memory in host ordering */ #define WRITEEF2BYTE (_ptr, _val) \ - do { \ - (*((u16 *)(_ptr))) = EF2BYTE(_val); \ - } while (0) + ((*((u16 *)(_ptr))) = EF2BYTE(_val))#define WRITEEF4BYTE (_ptr, _val) \ - do { \ - (*((u32 *)(_ptr))) = EF4BYTE(_val); \ - } while (0) + ((*((u32 *)(_ptr))) = EF4BYTE(_val))/* * Create a bit mask
Signature · 1 line
2.53.0
PATCH 4/4 staging: rtl8723bs: remove redundant blank lines in basic_types.h
In reply to Mashiro ChenRemove redundant blank lines at the top of the file to improve code cleanliness.
--- drivers/staging/rtl8723bs/include/basic_types.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/rtl8723bs/include/basic_types.h +0 -1
@@ -7,7 +7,6 @@#ifndef __BASIC_TYPES_H__#define __BASIC_TYPES_H__ -#define SUCCESS 0#define FAIL (-1)
Signature · 1 line
2.53.0