[PATCH 05/16] staging: ks7010: remove duplicate code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Current switch statement has duplicate code in branches. This code can
be put after the switch statement so as to remove the duplication.

Move code to after switch statement, remove duplicate code. Make error
branch return so as not to execute the moved code block. Do not change
the program logic.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks_hostif.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 8cfda60..8755bd9 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -462,17 +462,6 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 		memcpy(skb_put(skb, size), &eth_hdr->h_proto, size);
 
 		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
-		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-		    priv->wpa.rsn_enabled)
-			atomic_set(&priv->psstatus.snooze_guard, 1);
-
-		/* rx indication */
-		skb->dev = priv->net_dev;
-		skb->protocol = eth_type_trans(skb, skb->dev);
-		priv->nstats.rx_packets++;
-		priv->nstats.rx_bytes += rx_ind_size;
-		netif_rx(skb);
-
 		break;
 	case 0xF0:	/* NETBEUI/NetBIOS */
 		rx_ind_size = (priv->rx_size + 2);
@@ -493,22 +482,23 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 		       rx_ind_size - 14);	/* copy after Type */
 
 		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
-		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-		    priv->wpa.rsn_enabled)
-			atomic_set(&priv->psstatus.snooze_guard, 1);
-
-		/* rx indication */
-		skb->dev = priv->net_dev;
-		skb->protocol = eth_type_trans(skb, skb->dev);
-		priv->nstats.rx_packets++;
-		priv->nstats.rx_bytes += rx_ind_size;
-		netif_rx(skb);
-
 		break;
 	default:	/* other rx data */
 		DPRINTK(2, "invalid data format\n");
 		priv->nstats.rx_errors++;
+		return;
 	}
+
+	if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
+	    priv->wpa.rsn_enabled)
+		atomic_set(&priv->psstatus.snooze_guard, 1);
+
+	/* rx indication */
+	skb->dev = priv->net_dev;
+	skb->protocol = eth_type_trans(skb, skb->dev);
+	priv->nstats.rx_packets++;
+	priv->nstats.rx_bytes += rx_ind_size;
+	netif_rx(skb);
 }
 
 static
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux