Skip to contentSkip to conversation

staging: rtl8192e: Remove unncessary paranthesis.

PATCH In review Sanjana Sanikommu 2 participants 7 messages Mar 27, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8192e: Remove unncessary paranthesis.

Challenge suggested by coccinelle.
Remove unnecessary parathesis around the right hand of assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =
-(((e1) & (e2)) |
-(e3 << e4))
+(e1 & e2) |
+(e3 << e4)

---
Changes in v2:
Modify semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +8 -11
index 73497d559b77..5603570f6dda 100644
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 	if (dwBitMask != bMaskDWord) {
 		OriginalValue = rtl92e_readl(dev, dwRegAddr);
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
-		NewValue = (((OriginalValue) & (~dwBitMask)) |
-			    (dwData << BitShift));
+		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
 	} else
 		rtl92e_writel(dev, dwRegAddr, dwData);
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device *dev,
 		NewOffset = Offset;
 	}
 
-	DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+	DataAndAddr = (NewOffset & 0x3f) | (Data << 16);
 
 	rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
 
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath,
 								RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				    (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
 							     RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				     (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
 		} else
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev)
 
 	if (priv->IC_Cut  > VERSION_8190_BD) {
 		if (priv->rf_type == RF_2T4R)
-			dwRegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			dwRegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 		else
 			dwRegValue = 0x0;
 		rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel)
 			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
 			priv->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			u4RegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 
 			rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
 					  (bXBTxAGC|bXCTxAGC|bXDTxAGC),
Signature · 1 line
2.17.1
#1 lore raw

The word is parenthesis, plural parentheses. Please change both misspelled occurrences.

Quoted 44 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove unnecessary parathesis around the right hand of assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =

(quoted diff) +2 -2
-(((e1) & (e2)) |
-(e3 << e4))
+(e1 & e2) |
+(e3 << e4)

---
Changes in v2:
Modify semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
index 73497d559b77..5603570f6dda 100644
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 	if (dwBitMask != bMaskDWord) {
 		OriginalValue = rtl92e_readl(dev, dwRegAddr);
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
-		NewValue = (((OriginalValue) & (~dwBitMask)) |
-			    (dwData << BitShift));
+		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
 	} else
 		rtl92e_writel(dev, dwRegAddr, dwData);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device *dev, · line 190

Quoted 5 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -1
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device *dev,
 		NewOffset = Offset;
 	}
 
-	DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+	DataAndAddr = (NewOffset & 0x3f) | (Data << 16);

I think that your added rule unnecessarily switched the expressions around here. Actually it matches your new rule backwards.

Quoted 13 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
 	rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
 
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath,
 								RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				    (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath, · line 238

Quoted 6 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
 							     RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				     (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);

You are going over 80 characters here. Coccinelle is not always so smart about whitespace issues, and you have to clean them up by hand.

julia

Quoted 37 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +4 -5
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
 		} else
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev)
 
 	if (priv->IC_Cut  > VERSION_8190_BD) {
 		if (priv->rf_type == RF_2T4R)
-			dwRegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			dwRegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 		else
 			dwRegValue = 0x0;
 		rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel)
 			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
 			priv->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			u4RegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 
 			rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
 					  (bXBTxAGC|bXCTxAGC|bXDTxAGC),
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190327151947.7909-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 4 lines · Julia Lawall

The word is parenthesis, plural parentheses. Please change both misspelled occurrences.

I will correct it.

Quoted 51 lines · Sanjana Sanikommu
Quoted 23 lines

Challenge suggested by coccinelle.
Remove unnecessary parathesis around the right hand of assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =

(quoted diff) +2 -2
-(((e1) & (e2)) | 
-(e3 << e4)) 
+(e1 & e2) | 
+(e3 << e4) 
Signed-off-by Sanjana Sanikommu <[email protected] <javascript:>>

Review

Quoted 8 lines

---
Changes in v2:
Modify semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++----------- 
 1 file changed, 8 insertions(+), 11 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_bb_reg(struct net_device *dev, u32

Quoted 4 lines

index 73497d559b77..5603570f6dda 100644

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 

dwRegAddr, u32 dwBitMask,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,

Quoted 6 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
         if (dwBitMask != bMaskDWord) { 
                 OriginalValue = rtl92e_readl(dev, dwRegAddr); 
                 BitShift = _rtl92e_calculate_bit_shift(dwBitMask); 
-                NewValue = (((OriginalValue) & (~dwBitMask)) | 
-                            (dwData << BitShift)); 
+                NewValue = (OriginalValue & ~dwBitMask) | (dwData << 

BitShift);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device

Quoted 4 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                 rtl92e_writel(dev, dwRegAddr, NewValue); 
         } else 
                 rtl92e_writel(dev, dwRegAddr, dwData); 
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device 

*dev,

Quoted 8 lines

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device *dev, · line 190

Quoted 5 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -1
                 NewOffset = Offset; 
         } 
 
-        DataAndAddr = (Data<<16) | (NewOffset&0x3f); 
+        DataAndAddr = (NewOffset & 0x3f) | (Data << 16); 

I think that your added rule unnecessarily switched the expressions around here. Actually it matches your new rule backwards.

Even I thought it for a while, but after switching expressions,I found it
adjusts spaces
around operators. If I remove the rule if affects parentheses around
(OriginalValue) and (~dwBitMask).
So I thought it would be fine :)

Quoted 25 lines

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device · line 191

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
         rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, 

DataAndAddr);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum 

rf90_radio_path eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 222

Quoted 1 line
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         Original_Value = _rtl92e_phy_rf_fw_read(dev, 

eRFPath,

Quoted 1 line
                                                                 RegAddr); 
Quoted 1 line

BitShift =

_rtl92e_calculate_bit_shift(BitMask);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,

Quoted 3 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
-                        New_Value = (((Original_Value) & (~BitMask)) | 
-                                    (Data << BitShift)); 
+                        New_Value = (Original_Value & ~BitMask) | (Data 

<< BitShift);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum

Quoted 4 lines

_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
New_Value);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum 

rf90_radio_path eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 235

Quoted 1 line
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         Original_Value = _rtl92e_phy_rf_read(dev, 

eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 237

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                                                              RegAddr); 
                         BitShift = 
Quoted 9 lines

_rtl92e_calculate_bit_shift(BitMask);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,

Quoted 3 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
-                        New_Value = (((Original_Value) & (~BitMask)) | 
-                                     (Data << BitShift)); 
+                        New_Value = (Original_Value & ~BitMask) | (Data 

<< BitShift);

You are going over 80 characters here. Coccinelle is not always so smart about whitespace issues, and you have to clean them up by hand.

I will handle this one :)

Quoted 49 lines

julia

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 239

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         _rtl92e_phy_rf_write(dev, eRFPath, RegAddr, 

New_Value);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static bool _rtl92e_bb_config_para_file(struct

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                 } else 
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct 

net_device *dev)

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_tx_power(struct net_device *dev, u8

Quoted 12 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +2 -2
         if (priv->IC_Cut  > VERSION_8190_BD) { 
                 if (priv->rf_type == RF_2T4R) 
-                        dwRegValue = (priv->AntennaTxPwDiff[2]<<8 | 
+                        dwRegValue = priv->AntennaTxPwDiff[2]<<8 | 
                                       priv->AntennaTxPwDiff[1]<<4 | 
-                                      priv->AntennaTxPwDiff[0]); 
+                                      priv->AntennaTxPwDiff[0]; 
                 else 
                         dwRegValue = 0x0; 
                 rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, 
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 

channel)

Quoted 16 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +2 -2
                         priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); 
                         priv->AntennaTxPwDiff[0] = 0; 
 
-                        u4RegValue = (priv->AntennaTxPwDiff[2]<<8 | 
+                        u4RegValue = priv->AntennaTxPwDiff[2]<<8 | 
                                       priv->AntennaTxPwDiff[1]<<4 | 
-                                      priv->AntennaTxPwDiff[0]); 
+                                      priv->AntennaTxPwDiff[0]; 
 
                         rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, 
                                           (bXBTxAGC|bXCTxAGC|bXDTxAGC), 
Signature · 4 lines
2.17.1 

-- 
You received this message because you are subscribed to the Google 

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected] <javascript:>.

Quoted 1 line

To post to this group, send email to [email protected]

<javascript:>.

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190327151947.7909-1-sanjana99reddy99%40gmail.com.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw

PATCH v3 1/1 staging: rtl8192e: Remove unnecessary parantheses.

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove unnecessary parantheses around the right hand of assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =
-(((e1) & (e2)) |
-(e3 << e4))
+(e1 & e2) |
+(e3 << e4)

---
Changes in v3:
Correct the spelling of paranthesis.

Changes in v2:
Add new rule to semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).
New rule rewrites (Data<<16) | (NewOffset&0x3f) backwards but adjusts space around operators.

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +8 -11
index 73497d559b77..5603570f6dda 100644
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 	if (dwBitMask != bMaskDWord) {
 		OriginalValue = rtl92e_readl(dev, dwRegAddr);
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
-		NewValue = (((OriginalValue) & (~dwBitMask)) |
-			    (dwData << BitShift));
+		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
 	} else
 		rtl92e_writel(dev, dwRegAddr, dwData);
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device *dev,
 		NewOffset = Offset;
 	}
 
-	DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+	DataAndAddr = (NewOffset & 0x3f) | (Data << 16);
 
 	rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
 
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath,
 								RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				    (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
 							     RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				     (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
 		} else
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev)
 
 	if (priv->IC_Cut  > VERSION_8190_BD) {
 		if (priv->rf_type == RF_2T4R)
-			dwRegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			dwRegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 		else
 			dwRegValue = 0x0;
 		rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel)
 			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
 			priv->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			u4RegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 
 			rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
 					  (bXBTxAGC|bXCTxAGC|bXDTxAGC),
Signature · 1 line
2.17.1
#4 lore raw

Re: [Outreachy kernel] [PATCH v3] staging: rtl8192e: Remove unnecessary parantheses.

Quoted 2 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove unnecessary parantheses around the right hand of

Parentheses. Not parantheses.

julia

Quoted 109 lines

assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =

(quoted diff) +2 -2
-(((e1) & (e2)) |
-(e3 << e4))
+(e1 & e2) |
+(e3 << e4)

---
Changes in v3:
Correct the spelling of paranthesis.

Changes in v2:
Add new rule to semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).
New rule rewrites (Data<<16) | (NewOffset&0x3f) backwards but adjusts space around operators.

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +8 -12
index 73497d559b77..5603570f6dda 100644
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 	if (dwBitMask != bMaskDWord) {
 		OriginalValue = rtl92e_readl(dev, dwRegAddr);
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
-		NewValue = (((OriginalValue) & (~dwBitMask)) |
-			    (dwData << BitShift));
+		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
 	} else
 		rtl92e_writel(dev, dwRegAddr, dwData);
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device *dev,
 		NewOffset = Offset;
 	}
 
-	DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+	DataAndAddr = (NewOffset & 0x3f) | (Data << 16);
 
 	rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
 
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath,
 								RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				    (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
 							     RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				     (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
 		} else
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev)
 
 	if (priv->IC_Cut  > VERSION_8190_BD) {
 		if (priv->rf_type == RF_2T4R)
-			dwRegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			dwRegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 		else
 			dwRegValue = 0x0;
 		rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel)
 			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
 			priv->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			u4RegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 
 			rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
 					  (bXBTxAGC|bXCTxAGC|bXDTxAGC),
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190327163003.9622-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw

Re: [Outreachy kernel] [PATCH v3] staging: rtl8192e: Remove unnecessary parantheses.

Quoted 10 lines · Julia Lawall
Quoted 2 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove unnecessary parantheses around the right hand of

Parentheses. Not parantheses.

Oh No... :) I will send them in v4

Quoted 135 lines

julia

Quoted 29 lines

assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =

(quoted diff) +2 -2
-(((e1) & (e2)) | 
-(e3 << e4)) 
+(e1 & e2) | 
+(e3 << e4) 
Signed-off-by Sanjana Sanikommu <[email protected] <javascript:>>

---
Changes in v3:
Correct the spelling of paranthesis.

Changes in v2:
Add new rule to semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).
New rule rewrites (Data<<16) | (NewOffset&0x3f) backwards but adjusts space around operators.

Review

Quoted 4 lines
 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++----------- 
 1 file changed, 8 insertions(+), 11 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_bb_reg(struct net_device *dev, u32

Quoted 4 lines

index 73497d559b77..5603570f6dda 100644

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 

dwRegAddr, u32 dwBitMask,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,

Quoted 6 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
         if (dwBitMask != bMaskDWord) { 
                 OriginalValue = rtl92e_readl(dev, dwRegAddr); 
                 BitShift = _rtl92e_calculate_bit_shift(dwBitMask); 
-                NewValue = (((OriginalValue) & (~dwBitMask)) | 
-                            (dwData << BitShift)); 
+                NewValue = (OriginalValue & ~dwBitMask) | (dwData << 

BitShift);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device

Quoted 4 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                 rtl92e_writel(dev, dwRegAddr, NewValue); 
         } else 
                 rtl92e_writel(dev, dwRegAddr, dwData); 
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device 

*dev,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static void _rtl92e_phy_rf_write(struct net_device *dev,

Quoted 7 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -1
                 NewOffset = Offset; 
         } 
 
-        DataAndAddr = (Data<<16) | (NewOffset&0x3f); 
+        DataAndAddr = (NewOffset & 0x3f) | (Data << 16); 
 
         rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, 

DataAndAddr);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum 

rf90_radio_path eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 222

Quoted 1 line
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         Original_Value = _rtl92e_phy_rf_fw_read(dev, 

eRFPath,

Quoted 1 line
                                                                 RegAddr); 
Quoted 1 line

BitShift =

_rtl92e_calculate_bit_shift(BitMask);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,

Quoted 3 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
-                        New_Value = (((Original_Value) & (~BitMask)) | 
-                                    (Data << BitShift)); 
+                        New_Value = (Original_Value & ~BitMask) | (Data 

<< BitShift);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum

Quoted 4 lines

_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
New_Value);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum 

rf90_radio_path eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 235

Quoted 1 line
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         Original_Value = _rtl92e_phy_rf_read(dev, 

eRFPath,

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 237

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                                                              RegAddr); 
                         BitShift = 

_rtl92e_calculate_bit_shift(BitMask);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,

Quoted 3 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -2
-                        New_Value = (((Original_Value) & (~BitMask)) | 
-                                     (Data << BitShift)); 
+                        New_Value = (Original_Value & ~BitMask) | (Data 

<< BitShift);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_rf_reg(struct net_device *dev, enum · line 239

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                         _rtl92e_phy_rf_write(dev, eRFPath, RegAddr, 

New_Value);

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c static bool _rtl92e_bb_config_para_file(struct

Quoted 2 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +0 -0
                 } else 
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct 

net_device *dev)

drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c void rtl92e_set_tx_power(struct net_device *dev, u8

Quoted 12 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +2 -2
         if (priv->IC_Cut  > VERSION_8190_BD) { 
                 if (priv->rf_type == RF_2T4R) 
-                        dwRegValue = (priv->AntennaTxPwDiff[2]<<8 | 
+                        dwRegValue = priv->AntennaTxPwDiff[2]<<8 | 
                                       priv->AntennaTxPwDiff[1]<<4 | 
-                                      priv->AntennaTxPwDiff[0]); 
+                                      priv->AntennaTxPwDiff[0]; 
                 else 
                         dwRegValue = 0x0; 
                 rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, 
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 

channel)

Quoted 16 lines
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +2 -2
                         priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); 
                         priv->AntennaTxPwDiff[0] = 0; 
 
-                        u4RegValue = (priv->AntennaTxPwDiff[2]<<8 | 
+                        u4RegValue = priv->AntennaTxPwDiff[2]<<8 | 
                                       priv->AntennaTxPwDiff[1]<<4 | 
-                                      priv->AntennaTxPwDiff[0]); 
+                                      priv->AntennaTxPwDiff[0]; 
 
                         rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, 
                                           (bXBTxAGC|bXCTxAGC|bXDTxAGC), 
Signature · 4 lines
2.17.1 

-- 
You received this message because you are subscribed to the Google 

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected] <javascript:>.

Quoted 1 line

To post to this group, send email to [email protected]

<javascript:>.

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190327163003.9622-1-sanjana99reddy99%40gmail.com.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#6 lore raw

PATCH v4 1/1 staging: rtl8192e: Remove unnecessary parentheses.

In reply to Sanjana Sanikommu

Challenge suggested by coccinelle.
Remove unnecessary parentheses around the right hand of assignment using the below script.

@@
local idexpression id;
expression e;
@@

id =
-(
e
-)

@@ expression e, e1, e2,e3,e4; @@
e =
-(((e1) & (e2)) |
-(e3 << e4))
+(e1 & e2) |
+(e3 << e4)

---
Changes in v4:
Correct the spelling of parentheses

Changes in v3:
Correct the spelling of parentheses

Changes in v2:
Add new rule to semantic patch to remove unnecessary paranthesis around (OriginalValue) and (~dwBitMask).
New rule rewrites (Data<<16) | (NewOffset&0x3f) backwards but adjusts space around operators.

 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +8 -11
index 73497d559b77..5603570f6dda 100644
@@ -81,8 +81,7 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 	if (dwBitMask != bMaskDWord) {
 		OriginalValue = rtl92e_readl(dev, dwRegAddr);
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
-		NewValue = (((OriginalValue) & (~dwBitMask)) |
-			    (dwData << BitShift));
+		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
 	} else
 		rtl92e_writel(dev, dwRegAddr, dwData);
@@ -188,7 +187,7 @@ static void _rtl92e_phy_rf_write(struct net_device *dev,
 		NewOffset = Offset;
 	}
 
-	DataAndAddr = (Data<<16) | (NewOffset&0x3f);
+	DataAndAddr = (NewOffset & 0x3f) | (Data << 16);
 
 	rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
 
@@ -223,8 +222,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath,
 								RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				    (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);
@@ -237,8 +235,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
 							     RegAddr);
 			BitShift =  _rtl92e_calculate_bit_shift(BitMask);
-			New_Value = (((Original_Value) & (~BitMask)) |
-				     (Data << BitShift));
+			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
 		} else
@@ -571,9 +568,9 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev)
 
 	if (priv->IC_Cut  > VERSION_8190_BD) {
 		if (priv->rf_type == RF_2T4R)
-			dwRegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			dwRegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 		else
 			dwRegValue = 0x0;
 		rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
@@ -655,9 +652,9 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel)
 			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
 			priv->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
+			u4RegValue = priv->AntennaTxPwDiff[2]<<8 |
 				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+				      priv->AntennaTxPwDiff[0];
 
 			rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage,
 					  (bXBTxAGC|bXCTxAGC|bXDTxAGC),
Signature · 1 line
2.17.1