Skip to contentSkip to conversation

Staging: rtl8188eu: hal: Compress return logic into one line

PATCH Superseded Mihaela Muraru 2 participants 2 messages Oct 13, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: rtl8188eu: hal: Compress return logic into one line

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

-ret =
+return

        e;

-return ret;

---
Changes in v2:
- apply patch to the file.

---
 drivers/staging/rtl8188eu/hal/phy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8188eu/hal/phy.c +2 -4
index 5192ef7..a1c1a52 100644
@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask)
 
 	original_value = usb_read32(adapt, regaddr);
 	bit_shift = cal_bit_shift(bitmask);
-	return_value = (original_value & bitmask) >> bit_shift;
-	return return_value;
+	return (original_value & bitmask) >> bit_shift;
 }
 
 void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)
@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rf_path,
 
 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
 	bit_shift =  cal_bit_shift(bit_mask);
-	readback_value = (original_value & bit_mask) >> bit_shift;
-	return readback_value;
+	return (original_value & bit_mask) >> bit_shift;
 }
 
 void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 26 lines · Mihaela Muraru

Simplify function returns by merging assignment and return into one command line.
Found with Coccinelle
@@
expression e, ret;
@@

(quoted diff) +1 -2
-ret =
+return
        e;
-return ret;

---
Changes in v2:
- apply patch to the file.

---
 drivers/staging/rtl8188eu/hal/phy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8188eu/hal/phy.c +0 -0
index 5192ef7..a1c1a52 100644

drivers/staging/rtl8188eu/hal/phy.c u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask) · line 47

Quoted 6 lines
drivers/staging/rtl8188eu/hal/phy.c +1 -2
@@ -44,8 +44,7 @@ u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask)
 
 	original_value = usb_read32(adapt, regaddr);
 	bit_shift = cal_bit_shift(bitmask);
-	return_value = (original_value & bitmask) >> bit_shift;
-	return return_value;
+	return (original_value & bitmask) >> bit_shift;

Is the return_value variable still needed? If so, it could be useful to shorten the name in another patch. ret is more common in the kernel.

julia

Quoted 23 lines
drivers/staging/rtl8188eu/hal/phy.c +1 -3
 }
 
 void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)
@@ -123,8 +122,7 @@ u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rf_path,
 
 	original_value = rf_serial_read(adapt, rf_path, reg_addr);
 	bit_shift =  cal_bit_shift(bit_mask);
-	readback_value = (original_value & bit_mask) >> bit_shift;
-	return readback_value;
+	return (original_value & bit_mask) >> bit_shift;
 }
 
 void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,
--

2.7.4

--
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/20161013092141.GA7984%40domino-MS-16Y1.
For more options, visit https://groups.google.com/d/optout.