From 9afa937047b5c3dca3ed0bb6361eac06073c3efa Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 1 Jun 2016 14:56:52 +0530 Subject: [PATCH] rtl8192e: rtllib_device: Replace semaphore wx_sem with mutex The semaphore 'wx_sem' in the rtllib_device is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 +- drivers/staging/rtl8192e/rtllib.h | 5 +-- drivers/staging/rtl8192e/rtllib_softmac.c | 40 ++++++++++---------- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 34 ++++++++--------- drivers/staging/rtl8192e/rtllib_wx.c | 10 ++--- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 41e05f206300..f9e7a51316e5 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1277,14 +1277,14 @@ RESET_START: rtllib_stop_scan_syncro(ieee); if (ieee->state == RTLLIB_LINKED) { - SEM_DOWN_IEEE_WX(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); netdev_info(dev, "ieee->state is RTLLIB_LINKED\n"); rtllib_stop_send_beacons(priv->rtllib); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); rtllib_stop_scan(ieee); netif_carrier_off(dev); - SEM_UP_IEEE_WX(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } else { netdev_info(dev, "ieee->state is NOT LINKED\n"); rtllib_softmac_stop_protocol(priv->rtllib, 0, true); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 776e179d5bfd..513dd6153bd8 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -1651,7 +1652,7 @@ struct rtllib_device { short proto_started; short proto_stoppping; - struct semaphore wx_sem; + struct mutex wx_mutex; struct semaphore scan_sem; struct semaphore ips_sem; @@ -2212,7 +2213,5 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, void HTUseDefaultSetting(struct rtllib_device *ieee); #define RT_ASOC_RETRY_LIMIT 5 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee); -#define SEM_DOWN_IEEE_WX(psem) down(psem) -#define SEM_UP_IEEE_WX(psem) up(psem) #endif /* RTLLIB_H */ diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 62154e3f4463..901cc50a08d0 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -753,7 +753,7 @@ static void rtllib_start_scan(struct rtllib_device *ieee) } } -/* called with wx_sem held */ +/* called with wx_mutex held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { if (IS_DOT11D_ENABLE(ieee)) { @@ -1590,7 +1590,7 @@ static void rtllib_associate_procedure_wq(void *data) rtllib_stop_scan_syncro(ieee); if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); @@ -1605,14 +1605,14 @@ static void rtllib_associate_procedure_wq(void *data) __func__); if (ieee->rtllib_ips_leave_wq != NULL) ieee->rtllib_ips_leave_wq(ieee->dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return; } ieee->associate_seq = 1; rtllib_associate_step1(ieee, ieee->current_network.bssid); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void rtllib_softmac_new_net(struct rtllib_device *ieee, @@ -2582,16 +2582,16 @@ static void rtllib_start_ibss_wq(void *data) struct rtllib_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET - * operations because of the wx_sem hold. + * operations because of the wx_mutex hold. * Anyway some most set operations set a flag to speed-up * (abort) this wq (when syncro scanning) before sleeping - * on the semaphore + * on the mutex */ if (!ieee->proto_started) { netdev_info(ieee->dev, "==========oh driver down return\n"); return; } - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->current_network.ssid_len == 0) { strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); @@ -2703,7 +2703,7 @@ static void rtllib_start_ibss_wq(void *data) netif_carrier_on(ieee->dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void rtllib_start_ibss(struct rtllib_device *ieee) @@ -2711,7 +2711,7 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee) schedule_delayed_work(&ieee->start_ibss_wq, msecs_to_jiffies(150)); } -/* this is called only in user context, with wx_sem held */ +/* this is called only in user context, with wx_mutex held */ static void rtllib_start_bss(struct rtllib_device *ieee) { unsigned long flags; @@ -2773,7 +2773,7 @@ static void rtllib_associate_retry_wq(void *data) struct rtllib_device, associate_retry_wq); unsigned long flags; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (!ieee->proto_started) goto exit; @@ -2806,7 +2806,7 @@ static void rtllib_associate_retry_wq(void *data) ieee->beinretry = false; exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) @@ -2853,9 +2853,9 @@ void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) { rtllib_stop_scan_syncro(ieee); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); rtllib_stop_protocol(ieee, shutdown); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } EXPORT_SYMBOL(rtllib_softmac_stop_protocol); @@ -2902,9 +2902,9 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); rtllib_start_protocol(ieee); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } EXPORT_SYMBOL(rtllib_softmac_start_protocol); @@ -3034,7 +3034,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq, ieee); - sema_init(&ieee->wx_sem, 1); + mutex_init(&ieee->wx_mutex); sema_init(&ieee->scan_sem, 1); sema_init(&ieee->ips_sem, 1); @@ -3049,7 +3049,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; del_timer_sync(&ieee->associate_timer); @@ -3064,7 +3064,7 @@ void rtllib_softmac_free(struct rtllib_device *ieee) cancel_work_sync(&ieee->associate_complete_wq); cancel_work_sync(&ieee->ips_leave_wq); cancel_work_sync(&ieee->wx_sync_scan_wq); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); tasklet_kill(&ieee->ps_task); } @@ -3499,7 +3499,7 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, struct ieee_param *param; int ret = 0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; @@ -3543,7 +3543,7 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, kfree(param); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 61ed8b0413e4..5f1412fc410d 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -35,7 +35,7 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, int ret; struct iw_freq *fwrq = &wrqu->freq; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->iw_mode == IW_MODE_INFRA) { ret = 0; @@ -81,7 +81,7 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, ret = 0; out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(rtllib_wx_set_freq); @@ -146,7 +146,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, rtllib_stop_scan_syncro(ieee); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER) { ret = -1; @@ -185,7 +185,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, if (ifup) rtllib_start_protocol(ieee); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(rtllib_wx_set_wap); @@ -287,7 +287,7 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, int set_mode_status = 0; rtllib_stop_scan_syncro(ieee); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); switch (wrqu->mode) { case IW_MODE_MONITOR: case IW_MODE_ADHOC: @@ -322,7 +322,7 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, } out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return set_mode_status; } EXPORT_SYMBOL(rtllib_wx_set_mode); @@ -412,7 +412,7 @@ void rtllib_wx_sync_scan_wq(void *data) rtllib_wake_all_queues(ieee); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } @@ -421,7 +421,7 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, { int ret = 0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) { ret = -1; @@ -435,7 +435,7 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, } out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(rtllib_wx_set_scan); @@ -450,7 +450,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, unsigned long flags; rtllib_stop_scan_syncro(ieee); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); proto_started = ieee->proto_started; @@ -492,7 +492,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, if (proto_started) rtllib_start_protocol(ieee); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(rtllib_wx_set_essid); @@ -514,7 +514,7 @@ int rtllib_wx_set_rawtx(struct rtllib_device *ieee, int enable = (parms[0] > 0); short prev = ieee->raw_tx; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (enable) ieee->raw_tx = 1; @@ -536,7 +536,7 @@ int rtllib_wx_set_rawtx(struct rtllib_device *ieee, netif_carrier_off(ieee->dev); } - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; } @@ -575,7 +575,7 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, return -1; } - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (wrqu->power.disabled) { RT_TRACE(COMP_DBG, "===>%s(): power disable\n", __func__); @@ -611,7 +611,7 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, } exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } @@ -622,7 +622,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->ps == RTLLIB_PS_DISABLED) { wrqu->power.disabled = 1; @@ -648,7 +648,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, wrqu->power.flags |= IW_POWER_UNICAST_R; exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; } diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 84e6272f28cd..b1500ee9a5cf 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -263,7 +263,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, int err = 0; netdev_dbg(ieee->dev, "Getting scan\n"); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { @@ -287,7 +287,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, } spin_unlock_irqrestore(&ieee->lock, flags); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); wrqu->data.length = ev - extra; wrqu->data.flags = 0; @@ -689,7 +689,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, if (ieee->state != RTLLIB_LINKED) return -ENOLINK; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); switch (mlme->cmd) { case IW_MLME_DEAUTH: @@ -716,11 +716,11 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, ieee->current_network.ssid_len = 0; break; default: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return -EOPNOTSUPP; } - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; }