Commit f0a4c596 authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

staging: ks7010: reduce level of indentation

Checkpatch emits WARNING: Too many leading tabs - consider code
refactoring. One level of indentation may be removed by inverting an
if statement conditional (and returning if new conditional evaluates
to true). Code contains switch statement that also contains multiple
layers of indentation. Indentation may be reduced by breaking out of
the case statement in multiple places instead of guarding code with
if/else statements.

Invert conditional. Return original error code if new conditional
evaluates to true. Break out of case blocks instead of using
if/else. Do not modify program logic.
Signed-off-by: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f0b7d3a6
...@@ -1890,72 +1890,71 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, ...@@ -1890,72 +1890,71 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
if (dwrq->flags & IW_ENCODE_DISABLED) if (dwrq->flags & IW_ENCODE_DISABLED)
priv->wpa.key[index].key_len = 0; priv->wpa.key[index].key_len = 0;
if (enc) { if (!enc)
priv->wpa.key[index].ext_flags = enc->ext_flags; return -EINVAL;
if (enc->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
priv->wpa.txkey = index;
commit |= SME_WEP_INDEX;
} else if (enc->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
memcpy(&priv->wpa.key[index].rx_seq[0],
enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE);
}
memcpy(&priv->wpa.key[index].addr.sa_data[0], priv->wpa.key[index].ext_flags = enc->ext_flags;
&enc->addr.sa_data[0], ETH_ALEN); if (enc->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
priv->wpa.txkey = index;
commit |= SME_WEP_INDEX;
} else if (enc->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
memcpy(&priv->wpa.key[index].rx_seq[0],
enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE);
}
switch (enc->alg) { memcpy(&priv->wpa.key[index].addr.sa_data[0],
case IW_ENCODE_ALG_NONE: &enc->addr.sa_data[0], ETH_ALEN);
if (priv->reg.privacy_invoked) {
priv->reg.privacy_invoked = 0x00;
commit |= SME_WEP_FLAG;
}
priv->wpa.key[index].key_len = 0;
break; switch (enc->alg) {
case IW_ENCODE_ALG_WEP: case IW_ENCODE_ALG_NONE:
case IW_ENCODE_ALG_CCMP: if (priv->reg.privacy_invoked) {
if (!priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x00;
priv->reg.privacy_invoked = 0x01; commit |= SME_WEP_FLAG;
commit |= SME_WEP_FLAG; }
} priv->wpa.key[index].key_len = 0;
if (enc->key_len) {
memcpy(&priv->wpa.key[index].key_val[0], break;
&enc->key[0], enc->key_len); case IW_ENCODE_ALG_WEP:
priv->wpa.key[index].key_len = enc->key_len; case IW_ENCODE_ALG_CCMP:
commit |= (SME_WEP_VAL1 << index); if (!priv->reg.privacy_invoked) {
} priv->reg.privacy_invoked = 0x01;
break; commit |= SME_WEP_FLAG;
case IW_ENCODE_ALG_TKIP: }
if (!priv->reg.privacy_invoked) { if (enc->key_len) {
priv->reg.privacy_invoked = 0x01; memcpy(&priv->wpa.key[index].key_val[0],
commit |= SME_WEP_FLAG; &enc->key[0], enc->key_len);
} priv->wpa.key[index].key_len = enc->key_len;
if (enc->key_len == 32) { commit |= (SME_WEP_VAL1 << index);
memcpy(&priv->wpa.key[index].key_val[0], }
&enc->key[0], enc->key_len - 16); break;
priv->wpa.key[index].key_len = case IW_ENCODE_ALG_TKIP:
enc->key_len - 16; if (!priv->reg.privacy_invoked) {
if (priv->wpa.key_mgmt_suite == 4) { /* WPA_NONE */ priv->reg.privacy_invoked = 0x01;
memcpy(&priv->wpa.key[index]. commit |= SME_WEP_FLAG;
tx_mic_key[0], &enc->key[16], 8); }
memcpy(&priv->wpa.key[index]. if (enc->key_len == 32) {
rx_mic_key[0], &enc->key[16], 8); memcpy(&priv->wpa.key[index].key_val[0],
} else { &enc->key[0], enc->key_len - 16);
memcpy(&priv->wpa.key[index]. priv->wpa.key[index].key_len =
tx_mic_key[0], &enc->key[16], 8); enc->key_len - 16;
memcpy(&priv->wpa.key[index]. if (priv->wpa.key_mgmt_suite == 4) { /* WPA_NONE */
rx_mic_key[0], &enc->key[24], 8); memcpy(&priv->wpa.key[index].
} tx_mic_key[0], &enc->key[16], 8);
commit |= (SME_WEP_VAL1 << index); memcpy(&priv->wpa.key[index].
rx_mic_key[0], &enc->key[16], 8);
} else {
memcpy(&priv->wpa.key[index].
tx_mic_key[0], &enc->key[16], 8);
memcpy(&priv->wpa.key[index].
rx_mic_key[0], &enc->key[24], 8);
} }
break; commit |= (SME_WEP_VAL1 << index);
default:
return -EINVAL;
} }
priv->wpa.key[index].alg = enc->alg; break;
} else { default:
return -EINVAL; return -EINVAL;
} }
priv->wpa.key[index].alg = enc->alg;
if (commit) { if (commit) {
if (commit & SME_WEP_INDEX) if (commit & SME_WEP_INDEX)
...@@ -2025,51 +2024,53 @@ static int ks_wlan_set_pmksa(struct net_device *dev, ...@@ -2025,51 +2024,53 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
if (!memcmp if (!memcmp
("\x00\x00\x00\x00\x00\x00", pmk->bssid, ("\x00\x00\x00\x00\x00\x00", pmk->bssid,
ETH_ALEN)) ETH_ALEN))
break; break; /* loop */
} }
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head); list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++; priv->pmklist.size++;
} else { /* search cache data */ break; /* case */
list_for_each(ptr, &priv->pmklist.head) { }
pmk = list_entry(ptr, struct pmk_t, list); /* search cache data */
if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list move to head. */ list_for_each(ptr, &priv->pmklist.head) {
memcpy(pmk->pmkid, pmksa->pmkid, pmk = list_entry(ptr, struct pmk_t, list);
IW_PMKID_LEN); if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list move to head. */
list_move(&pmk->list, memcpy(pmk->pmkid, pmksa->pmkid,
&priv->pmklist.head); IW_PMKID_LEN);
break; list_move(&pmk->list,
} &priv->pmklist.head);
break; /* list_for_each */
} }
if (ptr == &priv->pmklist.head) { /* not find address. */ }
if (priv->pmklist.size <= PMK_LIST_MAX) { /* new cache data */ if (ptr != &priv->pmklist.head) /* not find address. */
for (i = 0; i < PMK_LIST_MAX; i++) { break; /* case */
pmk = &priv->pmklist.pmk[i];
if (!memcmp if (priv->pmklist.size <= PMK_LIST_MAX) { /* new cache data */
("\x00\x00\x00\x00\x00\x00", for (i = 0; i < PMK_LIST_MAX; i++) {
pmk->bssid, ETH_ALEN)) pmk = &priv->pmklist.pmk[i];
break; if (!memcmp
} ("\x00\x00\x00\x00\x00\x00",
memcpy(pmk->bssid, pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN))
ETH_ALEN); break;
memcpy(pmk->pmkid, pmksa->pmkid,
IW_PMKID_LEN);
list_add(&pmk->list,
&priv->pmklist.head);
priv->pmklist.size++;
} else { /* overwrite old cache data */
pmk =
list_entry(priv->pmklist.head.prev,
struct pmk_t, list);
memcpy(pmk->bssid, pmksa->bssid.sa_data,
ETH_ALEN);
memcpy(pmk->pmkid, pmksa->pmkid,
IW_PMKID_LEN);
list_move(&pmk->list,
&priv->pmklist.head);
}
} }
memcpy(pmk->bssid, pmksa->bssid.sa_data,
ETH_ALEN);
memcpy(pmk->pmkid, pmksa->pmkid,
IW_PMKID_LEN);
list_add(&pmk->list,
&priv->pmklist.head);
priv->pmklist.size++;
} else { /* overwrite old cache data */
pmk =
list_entry(priv->pmklist.head.prev,
struct pmk_t, list);
memcpy(pmk->bssid, pmksa->bssid.sa_data,
ETH_ALEN);
memcpy(pmk->pmkid, pmksa->pmkid,
IW_PMKID_LEN);
list_move(&pmk->list,
&priv->pmklist.head);
} }
break; break;
case IW_PMKSA_REMOVE: case IW_PMKSA_REMOVE:
......
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