Skip to contentSkip to conversation

staging: rtl8723bs: macro fixes in basic_types.h

PATCH Superseded Mashiro Chen 2 participants 7 messages Mar 28 – Mar 30 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 8adb95f9f..99b12c724 100644
@@ -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
#2 lore raw

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.

---
 drivers/staging/rtl8723bs/include/basic_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/basic_types.h +0 -0
index 8adb95f9f..99b12c724 100644

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 -1
 	do {						\
-		(*((u32 *)(_ptr))) = EF2BYTE(_val);	\
+		(*((u32 *)(_ptr))) = EF4BYTE(_val);	\
 	} while (0)
 
 /*
Signature · 1 line
2.53.0
#3 lore raw

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

#4 lore raw

PATCH 2/4 staging: rtl8723bs: wrap complex macros with parentheses

In reply to Mashiro Chen

Fix "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
index 99b12c724..edd64bcf2 100644
@@ -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
#5 lore raw

PATCH 3/4 staging: rtl8723bs: remove unnecessary do-while for macros

In reply to Mashiro Chen

Remove 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
index edd64bcf2..02965403e 100644
@@ -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
#6 lore raw

PATCH 4/4 staging: rtl8723bs: remove redundant blank lines in basic_types.h

In reply to Mashiro Chen

Remove 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
index 02965403e..304a17daa 100644
@@ -7,7 +7,6 @@
 #ifndef __BASIC_TYPES_H__
 #define __BASIC_TYPES_H__
 
-
 #define SUCCESS	0
 #define FAIL	(-1)
 
Signature · 1 line
2.53.0