[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5f3c9c1342a19b8dc0610c7ceb7cb6d2aabba44e.1441955761.git.raphael.beamonte@gmail.com>
Date: Fri, 11 Sep 2015 03:29:22 -0400
From: Raphaël Beamonte <raphael.beamonte@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Dan Carpenter <dan.carpenter@...cle.com>,
Raphaël Beamonte <raphael.beamonte@...il.com>,
Cristina Opriceana <cristina.opriceana@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCHv2 14/16] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function
Reorganize function rtl8192_ioctl to replace a switch with only
one case besides the default by an if statement. This also allows
to follow the 80 characters kernel code style rule.
Signed-off-by: Raphaël Beamonte <raphael.beamonte@...il.com>
---
drivers/staging/rtl8192u/r8192U_core.c | 141 ++++++++++++++++-----------------
1 file changed, 68 insertions(+), 73 deletions(-)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 189de56..f81f267 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3801,82 +3801,77 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
goto out;
}
- switch (cmd) {
- case RTL_IOCTL_WPA_SUPPLICANT:
- /* parse here for HW security */
- if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) {
- if (ipw->u.crypt.set_tx) {
- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- } else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
- ieee->pairwise_key_type = KEY_TYPE_TKIP;
- } else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
- if (ipw->u.crypt.key_len == 13)
- ieee->pairwise_key_type = KEY_TYPE_WEP104;
- else if (ipw->u.crypt.key_len == 5)
- ieee->pairwise_key_type = KEY_TYPE_WEP40;
- } else {
- ieee->pairwise_key_type = KEY_TYPE_NA;
- }
-
- if (ieee->pairwise_key_type) {
- memcpy((u8 *)key, ipw->u.crypt.key, 16);
- EnableHWSecurityConfig8192(dev);
- /* We fill both index entry and 4th
- * entry for pairwise key as in IPW
- * interface, adhoc will only get here,
- * so we need index entry for its
- * default key serching!
- */
- setKey(dev, 4, ipw->u.crypt.idx,
- ieee->pairwise_key_type,
- (u8 *)ieee->ap_mac_addr,
- 0, key);
- if (ieee->auth_mode != 2)
- setKey(dev, ipw->u.crypt.idx,
- ipw->u.crypt.idx,
- ieee->pairwise_key_type,
- (u8 *)ieee->ap_mac_addr,
- 0, key);
- }
- } else {
- memcpy((u8 *)key, ipw->u.crypt.key, 16);
- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
- ieee->group_key_type = KEY_TYPE_CCMP;
- } else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
- ieee->group_key_type = KEY_TYPE_TKIP;
- } else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
- if (ipw->u.crypt.key_len == 13)
- ieee->group_key_type = KEY_TYPE_WEP104;
- else if (ipw->u.crypt.key_len == 5)
- ieee->group_key_type = KEY_TYPE_WEP40;
- } else {
- ieee->group_key_type = KEY_TYPE_NA;
- }
-
- if (ieee->group_key_type) {
- setKey(dev, ipw->u.crypt.idx,
- /* KeyIndex */
- ipw->u.crypt.idx,
- /* KeyType */
- ieee->group_key_type,
- /* MacAddr */
- broadcast_addr,
- /* DefaultKey */
- 0,
- /* KeyContent */
- key);
- }
- }
+ if (cmd != RTL_IOCTL_WPA_SUPPLICANT) {
+ ret = -EOPNOTSUPP;
+ goto kfree;
+ }
+
+ /* parse here for HW security */
+ if (ipw->cmd != IEEE_CMD_SET_ENCRYPTION)
+ goto ret;
+
+ if (ipw->u.crypt.set_tx) {
+ if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+ ieee->pairwise_key_type = KEY_TYPE_CCMP;
+ } else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+ ieee->pairwise_key_type = KEY_TYPE_TKIP;
+ } else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+ if (ipw->u.crypt.key_len == 13)
+ ieee->pairwise_key_type = KEY_TYPE_WEP104;
+ else if (ipw->u.crypt.key_len == 5)
+ ieee->pairwise_key_type = KEY_TYPE_WEP40;
+ } else {
+ ieee->pairwise_key_type = KEY_TYPE_NA;
}
- ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
- &wrq->u.data);
- break;
- default:
- ret = -EOPNOTSUPP;
- break;
+ if (ieee->pairwise_key_type) {
+ memcpy((u8 *)key, ipw->u.crypt.key, 16);
+ EnableHWSecurityConfig8192(dev);
+ /* We fill both index entry and 4th
+ * entry for pairwise key as in IPW
+ * interface, adhoc will only get here,
+ * so we need index entry for its
+ * default key serching!
+ */
+ setKey(dev, 4, ipw->u.crypt.idx,
+ ieee->pairwise_key_type,
+ (u8 *)ieee->ap_mac_addr, 0, key);
+ if (ieee->auth_mode != 2)
+ setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx,
+ ieee->pairwise_key_type,
+ (u8 *)ieee->ap_mac_addr, 0, key);
+ }
+ } else {
+ memcpy((u8 *)key, ipw->u.crypt.key, 16);
+ if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+ ieee->group_key_type = KEY_TYPE_CCMP;
+ } else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+ ieee->group_key_type = KEY_TYPE_TKIP;
+ } else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+ if (ipw->u.crypt.key_len == 13)
+ ieee->group_key_type = KEY_TYPE_WEP104;
+ else if (ipw->u.crypt.key_len == 5)
+ ieee->group_key_type = KEY_TYPE_WEP40;
+ } else {
+ ieee->group_key_type = KEY_TYPE_NA;
+ }
+
+ if (ieee->group_key_type) {
+ setKey(dev, ipw->u.crypt.idx,
+ ipw->u.crypt.idx, /* KeyIndex */
+ ieee->group_key_type, /* KeyType */
+ broadcast_addr, /* MacAddr */
+ 0, /* DefaultKey */
+ key); /* KeyContent */
+
+ }
}
+
+ret:
+ ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
+ &wrq->u.data);
+
+kfree:
kfree(ipw);
ipw = NULL;
out:
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists