Commit 6b142341 authored by Chris Opperman's avatar Chris Opperman Committed by Greg Kroah-Hartman

staging: wlan-ng: improved readability of function prism2_add_key

Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.
Signed-off-by: default avatarChris Opperman <eklikeroomys@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c238d7b1
...@@ -148,40 +148,26 @@ static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev, ...@@ -148,40 +148,26 @@ static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev,
struct wlandevice *wlandev = dev->ml_priv; struct wlandevice *wlandev = dev->ml_priv;
u32 did; u32 did;
int err = 0;
int result = 0;
if (key_index >= NUM_WEPKEYS) if (key_index >= NUM_WEPKEYS)
return -EINVAL; return -EINVAL;
switch (params->cipher) { if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
case WLAN_CIPHER_SUITE_WEP40: params->cipher != WLAN_CIPHER_SUITE_WEP104) {
case WLAN_CIPHER_SUITE_WEP104:
result = prism2_domibset_uint32(wlandev,
DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
key_index);
if (result)
goto exit;
/* send key to driver */
did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
result = prism2_domibset_pstr32(wlandev, did,
params->key_len, params->key);
if (result)
goto exit;
break;
default:
pr_debug("Unsupported cipher suite\n"); pr_debug("Unsupported cipher suite\n");
result = 1; return -EFAULT;
} }
exit: if (prism2_domibset_uint32(wlandev,
if (result) DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
err = -EFAULT; key_index))
return -EFAULT;
return err; /* send key to driver */
did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
if (prism2_domibset_pstr32(wlandev, did, params->key_len, params->key))
return -EFAULT;
return 0;
} }
static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev, static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment