Skip to contentSkip to conversation

fix checkpatch error on macros

PATCH In review Fabio Aiuto 3 participants 27 messages Mar 27, 2021 – Mar 28, 2021 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover fix checkpatch error on macros

this patchset fixes, where possible, some checkpatch errors on macros. Delete unused macros and some unused struct fields tied
to removed macros.

Changes in v2:
- deleted unused macros
- ignored following checkpatch issues on macro:
* issues requiring to add parentheses to macro expanding in args of a function
* issues requiring to add parentheses to very complex and unreadable macro

Fabio Aiuto (20):
staging: rtl8723bs: remove unused macros in include/hal_com.h
staging: rtl8723bs: put parentheses on macro with complex values in
include/hal_com.h
staging: rtl8723bs: added spaces around operators in a macro in
include/hal_com.h
staging: rtl8723bs: remove unused macros in include/hal_com_reg.h
staging: rtl8723bs: remove unused macros in include/hal_data.h
staging: rtl8723bs: put parentheses on macros with complex values in
include/hal_data.h
staging: rtl8723bs: add spaces around operators in include/hal_data.h
staging: rtl8723bs: remove unused macros in include/hal_phy.h
staging: rtl8723bs: put parentheses on macros with complex values in
include/rtw_debug.h
staging: rtl8723bs: remove unused macro in include/rtw_pwrctrl.h
staging: rtl8723bs: remove unused field in rereg_nd_name_data struct
staging: rtl8723bs: remove commented code line in os_dep/ioctl_linux.c
staging: rtl8723bs: put parentheses on macros with complex values in
include/rtw_pwrctrl.h
staging: rtl8723bs: add spaces around operator in
include/rtw_pwrctrl.h
staging: rtl8723bs: remove unused macros in include/wifi.h
staging: rtl8723bs: put parentheses on macros with complex values in
include/wifi.h
staging: rtl8723bs: remove macros updating unused fields in struct
security_priv
staging: rtl8723bs: remove unused fields in struct security_priv
staging: rtl8723bs: include macro in a do - while loop in
core/rtw_security.c
staging: rtl8723bs: remove unused macros in include/drv_types.c

 drivers/staging/rtl8723bs/core/rtw_security.c | 78 ++-----------------
 drivers/staging/rtl8723bs/include/drv_types.h |  6 --
 drivers/staging/rtl8723bs/include/hal_com.h   |  6 +-
 .../staging/rtl8723bs/include/hal_com_reg.h   |  8 --
 drivers/staging/rtl8723bs/include/hal_data.h  |  9 +--
 drivers/staging/rtl8723bs/include/hal_phy.h   | 11 ---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 +++----
 .../staging/rtl8723bs/include/rtw_pwrctrl.h   |  7 +-
 .../staging/rtl8723bs/include/rtw_security.h  | 23 ------
 drivers/staging/rtl8723bs/include/wifi.h      | 48 ++++--------
 .../staging/rtl8723bs/os_dep/ioctl_linux.c    |  1 -
 11 files changed, 39 insertions(+), 186 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/20 staging: rtl8723bs: remove unused macros in include/hal_com.h

remove declarations of unused macros in include/hal_com.h

---
 drivers/staging/rtl8723bs/include/hal_com.h | 4 ----
 1 file changed, 4 deletions(-)
drivers/staging/rtl8723bs/include/hal_com.h +0 -4
index 3629b912698a..dc023dd17534 100644
@@ -181,10 +181,6 @@ enum rt_media_status {
 #define TX_SELE_EQ			BIT(3)		/*  Extern Queue */
 
 #define PageNum_128(_Len)		(u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0))
-#define PageNum_256(_Len)		(u32)(((_Len)>>8) + ((_Len)&0xFF ? 1:0))
-#define PageNum_512(_Len)		(u32)(((_Len)>>9) + ((_Len)&0x1FF ? 1:0))
-#define PageNum(_Len, _Size)		(u32)(((_Len)/(_Size)) + ((_Len)&((_Size) - 1) ? 1:0))
-
 
 u8 rtw_hal_data_init(struct adapter *padapter);
 void rtw_hal_data_deinit(struct adapter *padapter);
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 2/20 staging: rtl8723bs: put parentheses on macro with complex values in include/hal_com.h

In reply to Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros with complex values should be enclosed in parentheses 187: FILE: drivers/staging/rtl8723bs/include/hal_com.h:187:
+#define PageNum_128(_Len)

                (u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0))
---
 drivers/staging/rtl8723bs/include/hal_com.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_com.h +1 -1
index dc023dd17534..55f9caee6610 100644
@@ -180,7 +180,7 @@ enum rt_media_status {
 #define TX_SELE_NQ			BIT(2)		/*  Normal Queue */
 #define TX_SELE_EQ			BIT(3)		/*  Extern Queue */
 
-#define PageNum_128(_Len)		(u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0))
+#define PageNum_128(_Len)		((u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0)))
 
 u8 rtw_hal_data_init(struct adapter *padapter);
 void rtw_hal_data_deinit(struct adapter *padapter);
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 3/20 staging: rtl8723bs: added spaces around operators in a macro in include/hal_com.h

In reply to Fabio Aiuto

added spaces around operators in macro expression

---
 drivers/staging/rtl8723bs/include/hal_com.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_com.h +1 -1
index 55f9caee6610..a1e1b76b5d8a 100644
@@ -180,7 +180,7 @@ enum rt_media_status {
 #define TX_SELE_NQ			BIT(2)		/*  Normal Queue */
 #define TX_SELE_EQ			BIT(3)		/*  Extern Queue */
 
-#define PageNum_128(_Len)		((u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0)))
+#define PageNum_128(_Len)		((u32)(((_Len) >> 7) + ((_Len) & 0x7F ? 1 : 0)))
 
 u8 rtw_hal_data_init(struct adapter *padapter);
 void rtw_hal_data_deinit(struct adapter *padapter);
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 4/20 staging: rtl8723bs: remove unused macros in include/hal_com_reg.h

In reply to Fabio Aiuto

remove declarations of unused macros in include/hal_com_reg.h

---
 drivers/staging/rtl8723bs/include/hal_com_reg.h | 8 --------
 1 file changed, 8 deletions(-)
drivers/staging/rtl8723bs/include/hal_com_reg.h +0 -8
index b555826760d0..2cd18eb57244 100644
@@ -707,14 +707,6 @@ Default: 00b.
 
 
 /*  ALL CCK Rate */
-#define	RATE_ALL_CCK				RATR_1M | RATR_2M | RATR_55M | RATR_11M
-#define	RATE_ALL_OFDM_AG			RATR_6M | RATR_9M | RATR_12M | RATR_18M | RATR_24M |\
-						RATR_36M | RATR_48M | RATR_54M
-#define	RATE_ALL_OFDM_1SS			RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | RATR_MCS3 |\
-						RATR_MCS4 | RATR_MCS5 | RATR_MCS6 | RATR_MCS7
-#define	RATE_ALL_OFDM_2SS			RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | RATR_MCS11 |\
-						RATR_MCS12 | RATR_MCS13 | RATR_MCS14 | RATR_MCS15
-
 #define RATE_BITMAP_ALL			0xFFFFF
 
 /*  Only use CCK 1M rate for ACK */
Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 5/20 staging: rtl8723bs: remove unused macros in include/hal_data.h

In reply to Fabio Aiuto

remove declarations of unused macros in include/hal_data.h

---
 drivers/staging/rtl8723bs/include/hal_data.h | 7 -------
 1 file changed, 7 deletions(-)
drivers/staging/rtl8723bs/include/hal_data.h +0 -7
index b5a0be35a6ce..93ee20e8e860 100644
@@ -50,12 +50,10 @@ enum rt_ampdu_burst {
 #define CHANNEL_MAX_NUMBER_2G		14
 #define CHANNEL_MAX_NUMBER_5G		54			/*  Please refer to "phy_GetChnlGroup8812A" and "Hal_ReadTxPowerInfo8812A" */
 #define CHANNEL_MAX_NUMBER_5G_80M	7
-#define CHANNEL_GROUP_MAX		3+9	/*  ch1~3, ch4~9, ch10~14 total three groups */
 #define MAX_PG_GROUP			13
 
 /*  Tx Power Limit Table Size */
 #define MAX_REGULATION_NUM			4
-#define MAX_RF_PATH_NUM_IN_POWER_LIMIT_TABLE	4
 #define MAX_2_4G_BANDWIDTH_NUM			4
 #define MAX_RATE_SECTION_NUM			10
 #define MAX_5G_BANDWIDTH_NUM			4
@@ -69,11 +67,6 @@ enum rt_ampdu_burst {
 /* define IQK_ADDA_REG_NUM		16 */
 
 /* define IQK_BB_REG_NUM			10 */
-#define IQK_BB_REG_NUM_92C	9
-#define IQK_BB_REG_NUM_92D	10
-#define IQK_BB_REG_NUM_test	6
-
-#define IQK_Matrix_Settings_NUM_92D	1+24+21
 
 /* define HP_THERMAL_NUM		8 */
 /*  duplicate code, will move to ODM ######### */
Signature · 1 line
2.20.1
#6 lore raw

PATCH v2 6/20 staging: rtl8723bs: put parentheses on macros with complex values in include/hal_data.h

In reply to Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros with complex values should be enclosed in parentheses 49: FILE: drivers/staging/rtl8723bs/include/hal_data.h:49:
+#define CHANNEL_MAX_NUMBER

               14+24+21        /*  14 is the max channel number */
---
 drivers/staging/rtl8723bs/include/hal_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_data.h +1 -1
index 93ee20e8e860..655528ab8c7c 100644
@@ -46,7 +46,7 @@ enum rt_ampdu_burst {
 	RT_AMPDU_BURST_8723B	= 7,
 };
 
-#define CHANNEL_MAX_NUMBER		14+24+21	/*  14 is the max channel number */
+#define CHANNEL_MAX_NUMBER		(14+24+21)	/*  14 is the max channel number */
 #define CHANNEL_MAX_NUMBER_2G		14
 #define CHANNEL_MAX_NUMBER_5G		54			/*  Please refer to "phy_GetChnlGroup8812A" and "Hal_ReadTxPowerInfo8812A" */
 #define CHANNEL_MAX_NUMBER_5G_80M	7
Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 7/20 staging: rtl8723bs: add spaces around operators in include/hal_data.h

In reply to Fabio Aiuto

add spaces around operators in a macro

---
 drivers/staging/rtl8723bs/include/hal_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/hal_data.h +1 -1
index 655528ab8c7c..df5c7b747498 100644
@@ -46,7 +46,7 @@ enum rt_ampdu_burst {
 	RT_AMPDU_BURST_8723B	= 7,
 };
 
-#define CHANNEL_MAX_NUMBER		(14+24+21)	/*  14 is the max channel number */
+#define CHANNEL_MAX_NUMBER		(14 + 24 + 21)	/*  14 is the max channel number */
 #define CHANNEL_MAX_NUMBER_2G		14
 #define CHANNEL_MAX_NUMBER_5G		54			/*  Please refer to "phy_GetChnlGroup8812A" and "Hal_ReadTxPowerInfo8812A" */
 #define CHANNEL_MAX_NUMBER_5G_80M	7
Signature · 1 line
2.20.1
#8 lore raw

PATCH v2 8/20 staging: rtl8723bs: remove unused macros in include/hal_phy.h

In reply to Fabio Aiuto

remove declarations of unused macros in include/hal_phy.h

---
 drivers/staging/rtl8723bs/include/hal_phy.h | 11 -----------
 1 file changed, 11 deletions(-)
drivers/staging/rtl8723bs/include/hal_phy.h +0 -11
index bf17a85b5959..521eb1c2efad 100644
@@ -20,17 +20,6 @@
 #define	HAL_RF_ENABLE				1
 #endif
 
-#define	RF6052_MAX_TX_PWR			0x3F
-#define	RF6052_MAX_REG_88E			0xFF
-#define	RF6052_MAX_REG_92C			0x7F
-
-#define	RF6052_MAX_REG	\
-		(RF6052_MAX_REG_88E > RF6052_MAX_REG_92C) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C
-
-#define GET_RF6052_REAL_MAX_REG(_Adapter)	RF6052_MAX_REG_92C
-
-#define	RF6052_MAX_PATH				2
-
 /*  */
 /*  Antenna detection method, i.e., using single tone detection or RSSI reported from each antenna detected. */
 /*  Added by Roger, 2013.05.22. */
Signature · 1 line
2.20.1
#9 lore raw

PATCH v2 9/20 staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_debug.h

In reply to Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects
+ #define RT_PRINT_DATA(_Comp, _Level,

	_TitleString, _HexData, _HexDataLen)			\
---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/include/rtw_debug.h +15 -13
index d1c557818305..b00f8a6c4312 100644
@@ -236,19 +236,21 @@
 #if	defined(_dbgdump)
 	#undef RT_PRINT_DATA
 	#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)			\
-		if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
-		{									\
-			int __i;								\
-			u8 *ptr = (u8 *)_HexData;				\
-			_dbgdump("%s", DRIVER_PREFIX);						\
-			_dbgdump(_TitleString);						\
-			for (__i = 0; __i < (int)_HexDataLen; __i++)				\
-			{								\
-				_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
-				if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
-			}								\
-			_dbgdump("\n");							\
-		}
+		do { \
+			if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
+			{									\
+				int __i;								\
+				u8 *ptr = (u8 *)_HexData;				\
+				_dbgdump("%s", DRIVER_PREFIX);						\
+				_dbgdump(_TitleString);						\
+				for (__i = 0; __i < (int)_HexDataLen; __i++)				\
+				{								\
+					_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
+					if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
+				}								\
+				_dbgdump("\n");							\
+			} \
+		} while (0)
 #endif /* defined(_dbgdump) */
 #endif /* DEBUG_RTL871X */
 
Signature · 1 line
2.20.1
#14 lore raw

PATCH v2 10/20 staging: rtl8723bs: remove unused macro in include/rtw_pwrctrl.h

In reply to Fabio Aiuto

remove unused macro reading field ips_mode_req of struct pwrctrl_priv

---
 drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +0 -3
index 2d77446e9482..36d9ec82a7dc 100644
@@ -237,9 +237,6 @@ struct pwrctrl_priv {
 	unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT];
 };
 
-#define rtw_get_ips_mode_req(pwrctl) \
-	(pwrctl)->ips_mode_req
-
 #define rtw_ips_mode_req(pwrctl, ips_mode) \
 	(pwrctl)->ips_mode_req = (ips_mode)
 
Signature · 1 line
2.20.1
#15 lore raw

PATCH v2 11/20 staging: rtl8723bs: remove unused field in rereg_nd_name_data struct

In reply to Fabio Aiuto

remove unused field old_ips_mode in struct rereg_nd_name_data

---
 drivers/staging/rtl8723bs/include/drv_types.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtl8723bs/include/drv_types.h +0 -1
index df1dd9fa7b90..7eb59a16d00e 100644
@@ -412,7 +412,6 @@ struct adapter {
 	struct rereg_nd_name_data {
 		struct net_device *old_pnetdev;
 		char old_ifname[IFNAMSIZ];
-		u8 old_ips_mode;
 		u8 old_bRegUseLed;
 	} rereg_nd_name_priv;
 
Signature · 1 line
2.20.1
#16 lore raw

PATCH v2 12/20 staging: rtl8723bs: remove commented code line in os_dep/ioctl_linux.c

In reply to Fabio Aiuto

remove commented code line using obsolete definitions

---
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +0 -1
index eac98e455413..354441e6a667 100644
@@ -2618,7 +2618,6 @@ static int rtw_rereg_nd_name(struct net_device *dev,
 		rtw_free_network_queue(padapter, true);
 
 		/*  the interface is being "disabled", we can do deeper IPS */
-		/* rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); */
 		/* rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); */
 	}
 exit:
Signature · 1 line
2.20.1
#17 lore raw

PATCH v2 13/20 staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_pwrctrl.h

In reply to Fabio Aiuto

fix the following checkpatch warnings:

ERROR: Macros with complex values should be enclosed in parentheses 92: FILE: drivers/staging/rtl8723bs/include/rtw_pwrctrl.h:92:
+#define LPS_DELAY_TIME 1*HZ /* 1 sec */
--
ERROR: Macros with complex values should be enclosed in parentheses 244: FILE: drivers/staging/rtl8723bs/include/rtw_pwrctrl.h:244:
+#define rtw_ips_mode_req(pwrctl, ips_mode) \

---
 drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +2 -2
index 36d9ec82a7dc..6b2be97c2c07 100644
@@ -89,7 +89,7 @@ struct reportpwrstate_parm {
 	unsigned short rsvd;
 };
 
-#define LPS_DELAY_TIME	1*HZ /*  1 sec */
+#define LPS_DELAY_TIME	(1*HZ) /*  1 sec */
 
 #define EXE_PWR_NONE	0x01
 #define EXE_PWR_IPS		0x02
@@ -238,7 +238,7 @@ struct pwrctrl_priv {
 };
 
 #define rtw_ips_mode_req(pwrctl, ips_mode) \
-	(pwrctl)->ips_mode_req = (ips_mode)
+	((pwrctl)->ips_mode_req = (ips_mode))
 
 #define RTW_PWR_STATE_CHK_INTERVAL 2000
 
Signature · 1 line
2.20.1
#18 lore raw

PATCH v2 14/20 staging: rtl8723bs: add spaces around operator in include/rtw_pwrctrl.h

In reply to Fabio Aiuto

fix post-commit hook checkpatch warning:

add a space around that '*'

---
 drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +1 -1
index 6b2be97c2c07..b052b86944c4 100644
@@ -89,7 +89,7 @@ struct reportpwrstate_parm {
 	unsigned short rsvd;
 };
 
-#define LPS_DELAY_TIME	(1*HZ) /*  1 sec */
+#define LPS_DELAY_TIME	(1 * HZ) /*  1 sec */
 
 #define EXE_PWR_NONE	0x01
 #define EXE_PWR_IPS		0x02
Signature · 1 line
2.20.1
#19 lore raw

PATCH v2 15/20 staging: rtl8723bs: remove unused macros in include/wifi.h

In reply to Fabio Aiuto

remove declarations of unused macros in include/wifi.h

---
 drivers/staging/rtl8723bs/include/wifi.h | 20 --------------------
 1 file changed, 20 deletions(-)
drivers/staging/rtl8723bs/include/wifi.h +0 -20
index 48db55419bb3..4f8d08c00694 100644
@@ -102,17 +102,11 @@ enum {
 
 #define GetToDs(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
 
-#define ClearToDs(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_))
-
 #define SetFrDs(pbuf)	\
 	*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
 
 #define GetFrDs(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
 
-#define ClearFrDs(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_))
-
 #define get_tofr_ds(pframe)	((GetToDs(pframe) << 1) | GetFrDs(pframe))
 
 #define SetMFrag(pbuf)	\
@@ -123,9 +117,6 @@ enum {
 #define ClearMFrag(pbuf)	\
 	*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
 
-#define SetRetry(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_)
-
 #define GetRetry(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
 
 #define ClearRetry(pbuf)	\
@@ -153,10 +144,6 @@ enum {
 #define GetPrivacy(pbuf)					\
 	(((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
 
-#define ClearPrivacy(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_PRIVACY_))
-
-
 #define GetOrder(pbuf)					\
 	(((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0)
 
@@ -222,15 +209,8 @@ enum {
 
 #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
 
-#define SetAMsdu(pbuf, amsdu)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)
-
 #define GetAid(pbuf)	(le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
 
-#define GetTid(pbuf)	(le16_to_cpu(*(__le16 *)((size_t)(pbuf) +	\
-			(((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ?	\
-			30 : 24))) & 0x000f)
-
 #define GetAddr1Ptr(pbuf)	((unsigned char *)((size_t)(pbuf) + 4))
 
 #define GetAddr2Ptr(pbuf)	((unsigned char *)((size_t)(pbuf) + 10))
Signature · 1 line
2.20.1
#20 lore raw

PATCH v2 16/20 staging: rtl8723bs: put parentheses on macros with complex values in include/wifi.h

In reply to Fabio Aiuto

fix the following checkpatch warnings:

ERROR: Macros with complex values should be enclosed in parentheses 114: FILE: drivers/staging/rtl8723bs/include/wifi.h:114:
+#define SetToDs(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 122: FILE: drivers/staging/rtl8723bs/include/wifi.h:122:
+#define SetFrDs(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 132: FILE: drivers/staging/rtl8723bs/include/wifi.h:132:
+#define SetMFrag(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 137: FILE: drivers/staging/rtl8723bs/include/wifi.h:137:
+#define ClearMFrag(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 145: FILE: drivers/staging/rtl8723bs/include/wifi.h:145:
+#define ClearRetry(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 148: FILE: drivers/staging/rtl8723bs/include/wifi.h:148:
+#define SetPwrMgt(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 153: FILE: drivers/staging/rtl8723bs/include/wifi.h:153:
+#define ClearPwrMgt(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 156: FILE: drivers/staging/rtl8723bs/include/wifi.h:156:
+#define SetMData(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 161: FILE: drivers/staging/rtl8723bs/include/wifi.h:161:
+#define ClearMData(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 164: FILE: drivers/staging/rtl8723bs/include/wifi.h:164:
+#define SetPrivacy(pbuf) \
--
ERROR: Macros with complex values should be enclosed in parentheses 220: FILE: drivers/staging/rtl8723bs/include/wifi.h:220:
+#define SetDuration(pbuf, dur) \
--
ERROR: Macros with complex values should be enclosed in parentheses 224: FILE: drivers/staging/rtl8723bs/include/wifi.h:224:
+#define SetPriority(pbuf, tid) \
--
ERROR: Macros with complex values should be enclosed in parentheses 229: FILE: drivers/staging/rtl8723bs/include/wifi.h:229:
+#define SetEOSP(pbuf, eosp) \
--
ERROR: Macros with complex values should be enclosed in parentheses 232: FILE: drivers/staging/rtl8723bs/include/wifi.h:232:
+#define SetAckpolicy(pbuf, ack) \

---
 drivers/staging/rtl8723bs/include/wifi.h | 28 ++++++++++++------------
 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/staging/rtl8723bs/include/wifi.h +14 -14
index 4f8d08c00694..69e714a6d87c 100644
@@ -98,48 +98,48 @@ enum {
 #define _ORDER_			BIT(15)
 
 #define SetToDs(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_))
 
 #define GetToDs(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
 
 #define SetFrDs(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_))
 
 #define GetFrDs(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
 
 #define get_tofr_ds(pframe)	((GetToDs(pframe) << 1) | GetFrDs(pframe))
 
 #define SetMFrag(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_))
 
 #define GetMFrag(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
 
 #define ClearMFrag(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
+	(*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)))
 
 #define GetRetry(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
 
 #define ClearRetry(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))
+	(*(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)))
 
 #define SetPwrMgt(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_))
 
 #define GetPwrMgt(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0)
 
 #define ClearPwrMgt(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))
+	(*(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)))
 
 #define SetMData(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_))
 
 #define GetMData(pbuf)	(((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0)
 
 #define ClearMData(pbuf)	\
-	*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))
+	(*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)))
 
 #define SetPrivacy(pbuf)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_))
 
 #define GetPrivacy(pbuf)					\
 	(((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
@@ -191,19 +191,19 @@ enum {
 	} while (0)
 
 #define SetDuration(pbuf, dur) \
-	*(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))
+	(*(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)))
 
 
 #define SetPriority(pbuf, tid)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
+	(*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
 
 #define GetPriority(pbuf)	((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
 
 #define SetEOSP(pbuf, eosp)	\
-		*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
+		(*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
 
 #define SetAckpolicy(pbuf, ack)	\
-	*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)
+	(*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
 
 #define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
 
Signature · 1 line
2.20.1
#21 lore raw

PATCH v2 17/20 staging: rtl8723bs: remove macros updating unused fields in struct security_priv

In reply to Fabio Aiuto

remove macros updating statistic fields in struct security_priv

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 68 -------------------
 1 file changed, 68 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +0 -68
index 44e2b362c867..0ddd7667a986 100644
@@ -29,63 +29,6 @@ const char *security_type_str(u8 value)
 	return NULL;
 }
 
-#ifdef DBG_SW_SEC_CNT
-#define WEP_SW_ENC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->wep_sw_enc_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->wep_sw_enc_cnt_mc++; \
-	else \
-		sec->wep_sw_enc_cnt_uc++;
-
-#define WEP_SW_DEC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->wep_sw_dec_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->wep_sw_dec_cnt_mc++; \
-	else \
-		sec->wep_sw_dec_cnt_uc++;
-
-#define TKIP_SW_ENC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->tkip_sw_enc_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->tkip_sw_enc_cnt_mc++; \
-	else \
-		sec->tkip_sw_enc_cnt_uc++;
-
-#define TKIP_SW_DEC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->tkip_sw_dec_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->tkip_sw_dec_cnt_mc++; \
-	else \
-		sec->tkip_sw_dec_cnt_uc++;
-
-#define AES_SW_ENC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->aes_sw_enc_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->aes_sw_enc_cnt_mc++; \
-	else \
-		sec->aes_sw_enc_cnt_uc++;
-
-#define AES_SW_DEC_CNT_INC(sec, ra) \
-	if (is_broadcast_mac_addr(ra)) \
-		sec->aes_sw_dec_cnt_bc++; \
-	else if (is_multicast_mac_addr(ra)) \
-		sec->aes_sw_dec_cnt_mc++; \
-	else \
-		sec->aes_sw_dec_cnt_uc++;
-#else
-#define WEP_SW_ENC_CNT_INC(sec, ra)
-#define WEP_SW_DEC_CNT_INC(sec, ra)
-#define TKIP_SW_ENC_CNT_INC(sec, ra)
-#define TKIP_SW_DEC_CNT_INC(sec, ra)
-#define AES_SW_ENC_CNT_INC(sec, ra)
-#define AES_SW_DEC_CNT_INC(sec, ra)
-#endif /* DBG_SW_SEC_CNT */
-
 /* WEP related ===== */
 
 struct arc4context {
@@ -256,8 +199,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
 				pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
 			}
 		}
-
-		WEP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
 	}
 }
 
@@ -305,8 +246,6 @@ void rtw_wep_decrypt(struct adapter  *padapter, u8 *precvframe)
 					crc[1], payload[length - 3],
 					crc[0], payload[length - 4]));
 		}
-
-		WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
 	}
 }
 
@@ -710,8 +649,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
 					pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
 				}
 			}
-
-			TKIP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
 		}
 	}
 	return res;
@@ -812,8 +749,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
 						crc[0], payload[length - 4]));
 				res = _FAIL;
 			}
-
-			TKIP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
 		} else {
 			RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__));
 			res = _FAIL;
@@ -1465,8 +1400,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
 				pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
 			}
 		}
-
-		AES_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
 	}
 	return res;
 }
@@ -1772,7 +1705,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
 
 			res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
 
-			AES_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
 		} else {
 			RT_TRACE(_module_rtl871x_security_c_,
 				 _drv_err_,
Signature · 1 line
2.20.1
#22 lore raw

PATCH v2 18/20 staging: rtl8723bs: remove unused fields in struct security_priv

In reply to Fabio Aiuto

remove unused fields in struct security_priv

---
 .../staging/rtl8723bs/include/rtw_security.h  | 23 -------------------
 1 file changed, 23 deletions(-)
drivers/staging/rtl8723bs/include/rtw_security.h +0 -23
index 60b05a620eee..b71f0959108b 100644
@@ -168,29 +168,6 @@ struct security_priv {
 
 	u8 bWepDefaultKeyIdxSet;
 
-#define DBG_SW_SEC_CNT
-#ifdef DBG_SW_SEC_CNT
-	u64 wep_sw_enc_cnt_bc;
-	u64 wep_sw_enc_cnt_mc;
-	u64 wep_sw_enc_cnt_uc;
-	u64 wep_sw_dec_cnt_bc;
-	u64 wep_sw_dec_cnt_mc;
-	u64 wep_sw_dec_cnt_uc;
-
-	u64 tkip_sw_enc_cnt_bc;
-	u64 tkip_sw_enc_cnt_mc;
-	u64 tkip_sw_enc_cnt_uc;
-	u64 tkip_sw_dec_cnt_bc;
-	u64 tkip_sw_dec_cnt_mc;
-	u64 tkip_sw_dec_cnt_uc;
-
-	u64 aes_sw_enc_cnt_bc;
-	u64 aes_sw_enc_cnt_mc;
-	u64 aes_sw_enc_cnt_uc;
-	u64 aes_sw_dec_cnt_bc;
-	u64 aes_sw_dec_cnt_mc;
-	u64 aes_sw_dec_cnt_uc;
-#endif /* DBG_SW_SEC_CNT */
 };
 
 #define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)\
Signature · 1 line
2.20.1
#23 lore raw

PATCH v2 19/20 staging: rtl8723bs: include macro in a do - while loop in core/rtw_security.c

In reply to Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros with multiple statements should be enclosed in a do - while loop
2014: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:2014:
+#define ROUND(i, d, s) \

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +6 -4
index 0ddd7667a986..8a447e149438 100644
@@ -2012,10 +2012,12 @@ static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16])
 	s3 = GETU32(pt + 12) ^ rk[3];
 
 #define ROUND(i, d, s) \
-d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
-d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
-d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
-d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+	do { \
+		d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+		d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+		d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+		d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
+	} while (0)
 
 	/* Nr - 1 full rounds: */
 	r = Nr >> 1;
Signature · 1 line
2.20.1
#26 lore raw

PATCH v2 20/20 staging: rtl8723bs: remove unused macros in include/drv_types.c

In reply to Fabio Aiuto

remove declarations of unused macros

---
 drivers/staging/rtl8723bs/include/drv_types.h | 5 -----
 1 file changed, 5 deletions(-)
drivers/staging/rtl8723bs/include/drv_types.h +0 -5
index 7eb59a16d00e..a454a6390537 100644
@@ -266,11 +266,6 @@ struct cam_entry_cache {
 	u8 key[16];
 };
 
-#define KEY_FMT "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
-#define KEY_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5], \
-	((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \
-	((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15]
-
 struct dvobj_priv {
 	/*-------- below is common data --------*/
 	struct adapter *if1; /* PRIMARY_ADAPTER */
Signature · 1 line
2.20.1
#10 lore raw

Re: [PATCH v2 09/20] staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_debug.h

In reply to Fabio Aiuto
Quoted 8 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects

(quoted diff) +1 -0
+	#define RT_PRINT_DATA(_Comp, _Level,
	_TitleString, _HexData, _HexDataLen)			\

It's good to use checkpatch as a guide to improve code, but this particular code is just a mess to begin with and it makes a complete mess of the the dmesg log if it's actually enabled.

Try substituting print_hex_dump_debug for this instead.

Quoted 44 lines

---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 ++++++++++---------

 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/include/rtw_debug.h +15 -13
index d1c557818305..b00f8a6c4312 100644
@@ -236,19 +236,21 @@
  #if	defined(_dbgdump)
  	#undef RT_PRINT_DATA
  	#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)			\
-		if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
-		{									\
-			int __i;								\
-			u8 *ptr = (u8 *)_HexData;				\
-			_dbgdump("%s", DRIVER_PREFIX);						\
-			_dbgdump(_TitleString);						\
-			for (__i = 0; __i < (int)_HexDataLen; __i++)				\
-			{								\
-				_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
-				if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
-			}								\
-			_dbgdump("\n");							\
-		}
+		do { \
+			if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
+			{									\
+				int __i;								\
+				u8 *ptr = (u8 *)_HexData;				\
+				_dbgdump("%s", DRIVER_PREFIX);						\
+				_dbgdump(_TitleString);						\
+				for (__i = 0; __i < (int)_HexDataLen; __i++)				\
+				{								\
+					_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
+					if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
+				}								\
+				_dbgdump("\n");							\
+			} \
+		} while (0)
  #endif /* defined(_dbgdump) */
  #endif /* DEBUG_RTL871X */

maintainer
#11 lore raw

Re: [PATCH v2 09/20] staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_debug.h

In reply to Fabio Aiuto
Quoted 23 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects

(quoted diff) +1 -0
+	#define RT_PRINT_DATA(_Comp, _Level,
	_TitleString, _HexData, _HexDataLen)			\
---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -3
index d1c557818305..b00f8a6c4312 100644
@@ -236,19 +236,21 @@
 #if	defined(_dbgdump)
 	#undef RT_PRINT_DATA
 	#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)			\
-		if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
-		{									\
-			int __i;								\

drivers/staging/rtl8723bs/include/rtw_debug.h line 251

Quoted 10 lines
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -10
-			u8 *ptr = (u8 *)_HexData;				\
-			_dbgdump("%s", DRIVER_PREFIX);						\
-			_dbgdump(_TitleString);						\
-			for (__i = 0; __i < (int)_HexDataLen; __i++)				\
-			{								\
-				_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
-				if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
-			}								\
-			_dbgdump("\n");							\
-		}

This whole nightmare needs to just be deleted and any callers of it need to use the in-kernel functions for this instead.

thanks,

greg k-h

maintainer
#24 lore raw

Re: [PATCH v2 19/20] staging: rtl8723bs: include macro in a do - while loop in core/rtw_security.c

In reply to Fabio Aiuto
Quoted 20 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros with multiple statements should be enclosed in a do - while loop
2014: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:2014:
+#define ROUND(i, d, s) \

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +0 -0
index 0ddd7667a986..8a447e149438 100644
@@ -2012,10 +2012,12 @@ static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16])
 	s3 = GETU32(pt + 12) ^ rk[3];
 
 #define ROUND(i, d, s) \

drivers/staging/rtl8723bs/core/rtw_security.c static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16]) · line 2020

Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_security.c +6 -4
-d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
-d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
-d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
-d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+	do { \
+		d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+		d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+		d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+		d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
+	} while (0)

Why is this code not using the in-kernel crypto code instead? I'll take this but that should be something that is done to this code eventually...

thanks,

greg k-h

#25 lore raw

Re: [PATCH v2 19/20] staging: rtl8723bs: include macro in a do - while loop in core/rtw_security.c

Quoted 36 lines · Greg KH
Quoted 20 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros with multiple statements should be enclosed in a do - while loop
2014: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:2014:
+#define ROUND(i, d, s) \

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +0 -0
index 0ddd7667a986..8a447e149438 100644
@@ -2012,10 +2012,12 @@ static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16])
 	s3 = GETU32(pt + 12) ^ rk[3];
 
 #define ROUND(i, d, s) \

drivers/staging/rtl8723bs/core/rtw_security.c static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16]) · line 2020

Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_security.c +6 -4
-d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
-d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
-d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
-d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+	do { \
+		d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+		d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+		d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+		d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
+	} while (0)

Why is this code not using the in-kernel crypto code instead? I'll take this but that should be something that is done to this code eventually...

Quoted 3 lines

thanks,

greg k-h

ok, I will indagate fo the fix.

thank you,

fabio

#12 lore raw

Re: [PATCH v2 09/20] staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_debug.h

In reply to Greg KH
Quoted 38 lines · Greg KH
Quoted 23 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects

(quoted diff) +1 -0
+	#define RT_PRINT_DATA(_Comp, _Level,
	_TitleString, _HexData, _HexDataLen)			\
---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -3
index d1c557818305..b00f8a6c4312 100644
@@ -236,19 +236,21 @@
 #if	defined(_dbgdump)
 	#undef RT_PRINT_DATA
 	#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)			\
-		if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
-		{									\
-			int __i;								\

drivers/staging/rtl8723bs/include/rtw_debug.h line 251

Quoted 10 lines
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -10
-			u8 *ptr = (u8 *)_HexData;				\
-			_dbgdump("%s", DRIVER_PREFIX);						\
-			_dbgdump(_TitleString);						\
-			for (__i = 0; __i < (int)_HexDataLen; __i++)				\
-			{								\
-				_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
-				if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
-			}								\
-			_dbgdump("\n");							\
-		}

This whole nightmare needs to just be deleted and any callers of it need to use the in-kernel functions for this instead.

Quoted 3 lines

thanks,

greg k-h

ok, will we get rid of the private debug level and components tracking as well?

Maybe encapsulating the built-in proposed by Joe, keeping the macro alive?

Thank you,

Fabio

maintainer
#13 lore raw

Re: [PATCH v2 09/20] staging: rtl8723bs: put parentheses on macros with complex values in include/rtw_debug.h

Quoted 39 lines · Fabio Aiuto
Quoted 38 lines · Greg KH
Quoted 23 lines · Fabio Aiuto

fix the following checkpatch warning:

ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects

(quoted diff) +1 -0
+	#define RT_PRINT_DATA(_Comp, _Level,
	_TitleString, _HexData, _HexDataLen)			\
---
 drivers/staging/rtl8723bs/include/rtw_debug.h | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -3
index d1c557818305..b00f8a6c4312 100644
@@ -236,19 +236,21 @@
 #if	defined(_dbgdump)
 	#undef RT_PRINT_DATA
 	#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen)			\
-		if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel))	\
-		{									\
-			int __i;								\

drivers/staging/rtl8723bs/include/rtw_debug.h line 251

Quoted 10 lines
drivers/staging/rtl8723bs/include/rtw_debug.h +0 -10
-			u8 *ptr = (u8 *)_HexData;				\
-			_dbgdump("%s", DRIVER_PREFIX);						\
-			_dbgdump(_TitleString);						\
-			for (__i = 0; __i < (int)_HexDataLen; __i++)				\
-			{								\
-				_dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?"  ":" ");	\
-				if (((__i + 1) % 16) == 0)	_dbgdump("\n");			\
-			}								\
-			_dbgdump("\n");							\
-		}

This whole nightmare needs to just be deleted and any callers of it need to use the in-kernel functions for this instead.

Quoted 5 lines
Quoted 3 lines

thanks,

greg k-h

ok, will we get rid of the private debug level and components tracking as well?

Please do.

Quoted 1 line

Maybe encapsulating the built-in proposed by Joe, keeping the macro alive?

No, do not keep it alive. Individual debugging/trace/info macros for drivers do not make sense at all. We have kernel-wide infrastructure for this, it is bold for an individual driver to somehow think that they need a "custom" solution for this instead.

Just use the normal apis, that is what they are there for.

thanks,

greg k-h