Commit 092f239e authored by Sergio Paracuellos's avatar Sergio Paracuellos Committed by Greg Kroah-Hartman

staging: ks7010: refactor ks_wlan_set_pmksa function

This commit cleans a bit ks_wlan_set_pmksa function removing
nonsense comments as well as make use of ether_addr_* family
functions written to not do manually things that were being
here. Minor single if brackets has been removed also.
Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bf338a90
......@@ -1694,68 +1694,65 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
switch (pmksa->cmd) {
case IW_PMKSA_ADD:
if (list_empty(&priv->pmklist.head)) { /* new list */
if (list_empty(&priv->pmklist.head)) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
if (memcmp("\x00\x00\x00\x00\x00\x00",
pmk->bssid, ETH_ALEN) == 0)
break; /* loop */
if (is_zero_ether_addr(pmk->bssid))
break;
}
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++;
break; /* case */
break;
}
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
pmk = list_entry(ptr, struct pmk, list);
if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) {
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
break; /* list_for_each */
break;
}
}
if (ptr != &priv->pmklist.head) /* not find address. */
break; /* case */
if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */
/* not find address. */
if (ptr != &priv->pmklist.head)
break;
/* new cache data */
if (priv->pmklist.size < PMK_LIST_MAX) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
if (memcmp("\x00\x00\x00\x00\x00\x00",
pmk->bssid, ETH_ALEN) == 0)
break; /* loop */
if (is_zero_ether_addr(pmk->bssid))
break;
}
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
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,
list);
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
}
break;
case IW_PMKSA_REMOVE:
if (list_empty(&priv->pmklist.head)) { /* list empty */
if (list_empty(&priv->pmklist.head))
return -EINVAL;
}
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
pmk = list_entry(ptr, struct pmk, list);
if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) {
eth_zero_addr(pmk->bssid);
memset(pmk->pmkid, 0, IW_PMKID_LEN);
list_del_init(&pmk->list);
break;
}
}
if (ptr == &priv->pmklist.head) { /* not find address. */
/* not find address. */
if (ptr == &priv->pmklist.head)
return 0;
}
break;
case IW_PMKSA_FLUSH:
memset(&priv->pmklist, 0, sizeof(priv->pmklist));
......
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