netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] igb: Convert a series of if statements to switch case
@ 2022-05-11  9:20 xiaolinkui
  2022-05-12 13:14 ` David Laight
  0 siblings, 1 reply; 5+ messages in thread
From: xiaolinkui @ 2022-05-11  9:20 UTC (permalink / raw)
  To: pmenzel, jesse.brandeburg, anthony.l.nguyen
  Cc: davem, edumazet, kuba, pabeni, intel-wired-lan, netdev,
	Linkui Xiao

From: Linkui Xiao <xiaolinkui@kylinos.cn>

Convert a series of if statements that handle different events to a switch
case statement to simplify the code.

V2: fix patch description and email format.

Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 34b33b21e0dc..4ce0718eeff6 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4588,13 +4588,17 @@ static inline void igb_set_vf_vlan_strip(struct igb_adapter *adapter,
 	struct e1000_hw *hw = &adapter->hw;
 	u32 val, reg;
 
-	if (hw->mac.type < e1000_82576)
+	switch (hw->mac.type) {
+	case e1000_undefined:
+	case e1000_82575:
 		return;
-
-	if (hw->mac.type == e1000_i350)
+	case e1000_i350:
 		reg = E1000_DVMOLR(vfn);
-	else
+		break;
+	default:
 		reg = E1000_VMOLR(vfn);
+		break;
+	}
 
 	val = rd32(reg);
 	if (enable)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] igb: Convert a series of if statements to switch case
@ 2022-05-10  2:57 xiaolinkui
  0 siblings, 0 replies; 5+ messages in thread
From: xiaolinkui @ 2022-05-10  2:57 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen
  Cc: davem, edumazet, kuba, pabeni, intel-wired-lan, netdev,
	Linkui Xiao

From: Linkui Xiao<xiaolinkui@kylinos.cn>

Convert a series of if statements that handle different events to
a switch case statement to simplify the code.

Signed-off-by: Linkui Xiao<xiaolinkui@kylinos.cn>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 34b33b21e0dc..4ce0718eeff6 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4588,13 +4588,17 @@ static inline void igb_set_vf_vlan_strip(struct igb_adapter *adapter,
 	struct e1000_hw *hw = &adapter->hw;
 	u32 val, reg;
 
-	if (hw->mac.type < e1000_82576)
+	switch (hw->mac.type) {
+	case e1000_undefined:
+	case e1000_82575:
 		return;
-
-	if (hw->mac.type == e1000_i350)
+	case e1000_i350:
 		reg = E1000_DVMOLR(vfn);
-	else
+		break;
+	default:
 		reg = E1000_VMOLR(vfn);
+		break;
+	}
 
 	val = rd32(reg);
 	if (enable)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-12 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-11  9:20 [PATCH] igb: Convert a series of if statements to switch case xiaolinkui
2022-05-12 13:14 ` David Laight
2022-05-12 13:31   ` Linkui Xiao
2022-05-12 18:47   ` Tony Nguyen
  -- strict thread matches above, loose matches on Subject: below --
2022-05-10  2:57 xiaolinkui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).