mac80211: simplify key locking
Since I recently made station management able to sleep, I can now rework key management as well; since it will no longer need a spinlock and can also use a mutex instead, a bunch of code to allow drivers' set_key to sleep while key management is protected by a spinlock can now be removed. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
efe4c457a1
commit
ad0e2b5a00
@ -120,6 +120,9 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
struct ieee80211_key *key;
|
||||
int err;
|
||||
|
||||
if (!netif_running(dev))
|
||||
return -ENETDOWN;
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
switch (params->cipher) {
|
||||
@ -145,7 +148,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
if (!key)
|
||||
return -ENOMEM;
|
||||
|
||||
rcu_read_lock();
|
||||
mutex_lock(&sdata->local->sta_mtx);
|
||||
|
||||
if (mac_addr) {
|
||||
sta = sta_info_get_bss(sdata, mac_addr);
|
||||
@ -160,7 +163,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
|
||||
err = 0;
|
||||
out_unlock:
|
||||
rcu_read_unlock();
|
||||
mutex_unlock(&sdata->local->sta_mtx);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -174,7 +177,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
rcu_read_lock();
|
||||
mutex_lock(&sdata->local->sta_mtx);
|
||||
|
||||
if (mac_addr) {
|
||||
ret = -ENOENT;
|
||||
@ -202,7 +205,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
|
||||
ret = 0;
|
||||
out_unlock:
|
||||
rcu_read_unlock();
|
||||
mutex_unlock(&sdata->local->sta_mtx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -305,15 +308,10 @@ static int ieee80211_config_default_key(struct wiphy *wiphy,
|
||||
struct net_device *dev,
|
||||
u8 key_idx)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
rcu_read_lock();
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
ieee80211_set_default_key(sdata, key_idx);
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user