Skip to contentSkip to conversation

staging: fsl-dpaa2: replace simple switch case by if statement

PATCH In review [email protected] 3 participants 4 messages Mar 21, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: fsl-dpaa2: replace simple switch case by if statement

From: HariPrasath Elango <[email protected]>

Replace a couple of simple switch cases by if condition

---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +4 -7
index 070a3f2..fb517cb 100644
@@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 	u8 *p = data;
 	int i;
 
-	switch (stringset) {
-	case ETH_SS_STATS:
+	if (stringset == ETH_SS_STATS) {
 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
@@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		break;
 	}
 }
 
 static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset)
 {
-	switch (sset) {
-	case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */
+	if (sset == ETH_SS_STATS)
+		/* ethtool_get_stats(), ethtool_get_drvinfo() */
 		return DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS;
-	default:
+	else
 		return -EOPNOTSUPP;
-	}
 }
 
 /** Fill in hardware counters, as returned by MC.
Signature · 1 line
2.10.0.GIT
#1 lore raw

From: > [email protected]

Quoted 4 lines

Sent: 21 March 2018 11:16
From: HariPrasath Elango <[email protected]>

Replace a couple of simple switch cases by if condition

Why?
In principle extra 'case' might be needed in the future.

...

Quoted 16 lines
drivers/staging/fsl- renamed from drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -0

dpaa2/ethernet/dpaa2-ethtool.c
index 070a3f2..fb517cb 100644

drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +1 -2
@@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 	u8 *p = data;
 	int i;
 
-	switch (stringset) {
-	case ETH_SS_STATS:
+	if (stringset == ETH_SS_STATS) {
 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;

drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset, · line 184

Quoted 6 lines
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -1
@@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		break;
 	}
 }

...

David

#2 lore raw
Quoted 8 lines · David Laight

From: > [email protected]

Quoted 4 lines

Sent: 21 March 2018 11:16
From: HariPrasath Elango <[email protected]>

Replace a couple of simple switch cases by if condition

Why?
In principle extra 'case' might be needed in the future.

I had the same question when saw it.
It's better to keep things as is.

Quoted 36 lines

...

Quoted 18 lines
drivers/staging/fsl- renamed from drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -0

dpaa2/ethernet/dpaa2-ethtool.c
index 070a3f2..fb517cb 100644

drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +1 -2
@@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device
 *netdev, u32 stringset,
 	u8 *p = data;
 	int i;
 
-	switch (stringset) {
-	case ETH_SS_STATS:
+	if (stringset == ETH_SS_STATS) {
 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -0
 			p += ETH_GSTRING_LEN;

drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c static void dpaa2_eth_get_strings(struct net_device · line 185

Quoted 7 lines
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -1
@@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device
 *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		break;
 	}
 }

...

David

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Signature · 6 lines
Regards / Mit besten Grüßen,
Denis
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#3 lore raw
Quoted 5 lines · Denis Kirjanov
Quoted 4 lines · David Laight

From: > [email protected]

Quoted 3 lines

Sent: 21 March 2018 11:16
From: HariPrasath Elango <[email protected]>

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Replace a couple of simple switch cases by if condition

Why?
In principle extra 'case' might be needed in the future.

I had the same question when saw it.
It's better to keep things as is.

Quoted 2 lines

...

Hi, since the switch statement had only one case,I thought of doing this. If there are plans to add more cases, we can leave it like that.

thanks,
hari

Quoted 27 lines
Quoted 27 lines
Quoted 25 lines
drivers/staging/fsl- renamed from drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -0

dpaa2/ethernet/dpaa2-ethtool.c
index 070a3f2..fb517cb 100644

drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +1 -2
@@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device
 *netdev, u32 stringset,
 	u8 *p = data;
 	int i;
 
-	switch (stringset) {
-	case ETH_SS_STATS:
+	if (stringset == ETH_SS_STATS) {
 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +0 -1
 			p += ETH_GSTRING_LEN;
@@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device
 *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		break;
 	}
 }

...

Quoted 12 lines
Quoted 7 lines

David

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Signature · 2 lines
Regards / Mit besten Grüßen,
Denis

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel