Skip to content

Commit

Permalink
rtlwifi: Switch locking from semaphores to mutexes
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Larry Finger authored and John W. Linville committed Dec 16, 2010
1 parent 3cf0c8a commit 8a09d6d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions drivers/net/wireless/rtlwifi/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ int rtl_init_core(struct ieee80211_hw *hw)
}

/* <4> locks */
sema_init(&rtlpriv->locks.ips_sem, 1);
sema_init(&rtlpriv->locks.conf_sem, 1);
mutex_init(&rtlpriv->locks.ips_mutex);
mutex_init(&rtlpriv->locks.conf_mutex);
spin_lock_init(&rtlpriv->locks.irq_th_lock);
spin_lock_init(&rtlpriv->locks.h2c_lock);
spin_lock_init(&rtlpriv->locks.rf_ps_lock);
Expand Down
32 changes: 16 additions & 16 deletions drivers/net/wireless/rtlwifi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static int rtl_op_start(struct ieee80211_hw *hw)
return 0;
if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
return 0;
down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);
err = rtlpriv->intf_ops->adapter_start(hw);
if (err)
goto out;
rtl_watch_dog_timer_callback((unsigned long)hw);
out:
up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
return err;
}

Expand All @@ -68,7 +68,7 @@ static void rtl_op_stop(struct ieee80211_hw *hw)
mdelay(1);
}

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);

mac->link_state = MAC80211_NOLINK;
memset(mac->bssid, 0, 6);
Expand All @@ -79,7 +79,7 @@ static void rtl_op_stop(struct ieee80211_hw *hw)
rtl_deinit_deferred_work(hw);
rtlpriv->intf_ops->adapter_stop(hw);

up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
}

static int rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
Expand Down Expand Up @@ -119,7 +119,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,

rtl_ips_nic_on(hw);

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);
switch (vif->type) {
case NL80211_IFTYPE_STATION:
if (mac->beacon_enabled == 1) {
Expand Down Expand Up @@ -156,7 +156,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);

out:
up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
return err;
}

Expand All @@ -166,7 +166,7 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);

/* Free beacon resources */
if ((mac->opmode == NL80211_IFTYPE_AP) ||
Expand All @@ -190,7 +190,7 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw,
mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);

up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
}


Expand All @@ -202,7 +202,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct ieee80211_conf *conf = &hw->conf;

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);
if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/
RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
("IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"));
Expand Down Expand Up @@ -303,7 +303,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
hw->conf.channel_type);
}

up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);

return 0;
}
Expand Down Expand Up @@ -450,7 +450,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);

if ((vif->type == NL80211_IFTYPE_ADHOC) ||
(vif->type == NL80211_IFTYPE_AP) ||
Expand Down Expand Up @@ -700,7 +700,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
}

out:
up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
}

static u64 rtl_op_get_tsf(struct ieee80211_hw *hw)
Expand Down Expand Up @@ -852,7 +852,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
sta ? sta->addr : bcast_addr));
rtlpriv->sec.being_setkey = true;
rtl_ips_nic_on(hw);
down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);
/* <1> get encryption alg */
switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
Expand Down Expand Up @@ -970,7 +970,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
("cmd_err:%x!!!!:\n", cmd));
}
out_unlock:
up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
rtlpriv->sec.being_setkey = false;
return err;
}
Expand All @@ -986,7 +986,7 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
return;

down(&rtlpriv->locks.conf_sem);
mutex_lock(&rtlpriv->locks.conf_mutex);

/*if Radio On return true here */
radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
Expand All @@ -1004,7 +1004,7 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
}
}

up(&rtlpriv->locks.conf_sem);
mutex_unlock(&rtlpriv->locks.conf_mutex);
}

const struct ieee80211_ops rtl_ops = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/rtlwifi/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
enum rf_pwrstate rtstate;

down(&rtlpriv->locks.ips_sem);
mutex_lock(&rtlpriv->locks.ips_mutex);

if (ppsc->b_inactiveps) {
rtstate = ppsc->rfpwr_state;
Expand All @@ -303,7 +303,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
}
}

up(&rtlpriv->locks.ips_sem);
mutex_unlock(&rtlpriv->locks.ips_mutex);
}

/*for FW LPS*/
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/rtlwifi/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,8 @@ struct rtl_hal_cfg {

struct rtl_locks {
/*sem */
struct semaphore ips_sem;
struct semaphore conf_sem;
struct mutex ips_mutex;
struct mutex conf_mutex;

/*spin lock */
spinlock_t irq_th_lock;
Expand Down

0 comments on commit 8a09d6d

Please sign in to comment.