Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1228915
| From | Raphaël Beamonte <raphael.beamonte@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function |
| Date | 2015-09-20 19:20 +0200 |
| Message-ID | <qaQro-6fo-27@gated-at.bofh.it> (permalink) |
| References | <qaQrn-6fo-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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@gmail.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 7dc1b34..171a494 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3751,82 +3751,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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 07:10 +0200
Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:20 +0200
Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 20:30 +0200
[PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
[PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
Re: [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
[PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
[PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
[PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
[PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-21 06:40 +0200
Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-21 18:40 +0200
[PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
csiph-web