[PATCH 1/4] rtl8192u: r8192_priv: Replace semaphore wx_sem with mutex

From: Binoy Jayan
Date: Thu Jun 02 2016 - 00:58:36 EST


The semaphore 'wx_sem' in r8192_priv is a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@xxxxxxxxxx>
---
drivers/staging/rtl8192u/r8192U.h | 2 +-
drivers/staging/rtl8192u/r8192U_core.c | 28 ++++++------
drivers/staging/rtl8192u/r8192U_wx.c | 80 +++++++++++++++++-----------------
3 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index ee1c722..2780838 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -879,7 +879,7 @@ typedef struct r8192_priv {
/* If 1, allow bad crc frame, reception in monitor mode */
short crcmon;

- struct semaphore wx_sem;
+ struct mutex wx_mutex;
struct semaphore rf_sem; /* Used to lock rf write operation */

u8 rf_type; /* 0: 1T2R, 1: 2T4R */
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 849a95e..3d1b52f 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2373,7 +2373,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv)
{
spin_lock_init(&priv->tx_lock);
spin_lock_init(&priv->irq_lock);
- sema_init(&priv->wx_sem, 1);
+ mutex_init(&priv->wx_mutex);
sema_init(&priv->rf_sem, 1);
mutex_init(&priv->mutex);
}
@@ -3324,12 +3324,12 @@ RESET_START:

/* Set the variable for reset. */
priv->ResetProgress = RESET_TYPE_SILENT;
- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
if (priv->up == 0) {
RT_TRACE(COMP_ERR,
"%s():the driver is not up! return\n",
__func__);
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return;
}
priv->up = 0;
@@ -3356,7 +3356,7 @@ RESET_START:
netdev_dbg(dev, "ieee->state is NOT LINKED\n");
ieee80211_softmac_stop_protocol(priv->ieee80211);
}
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
RT_TRACE(COMP_RESET,
"%s():<==========down process is finished\n",
__func__);
@@ -3556,9 +3556,9 @@ static int rtl8192_open(struct net_device *dev)
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
ret = rtl8192_up(dev);
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;

}
@@ -3580,11 +3580,11 @@ static int rtl8192_close(struct net_device *dev)
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = rtl8192_down(dev);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;

@@ -3658,11 +3658,11 @@ static void rtl8192_restart(struct work_struct *work)
reset_wq);
struct net_device *dev = priv->ieee80211->dev;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

rtl8192_commit(dev);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
}

static void r8192_set_multicast(struct net_device *dev)
@@ -3685,12 +3685,12 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac)
struct r8192_priv *priv = ieee80211_priv(dev);
struct sockaddr *addr = mac;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ether_addr_copy(dev->dev_addr, addr->sa_data);

schedule_work(&priv->reset_wq);
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return 0;
}
@@ -3707,7 +3707,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
struct iw_point *p = &wrq->u.data;
struct ieee_param *ipw = NULL;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);


if (p->length < sizeof(struct ieee_param) || !p->pointer) {
@@ -3800,7 +3800,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
kfree(ipw);
ipw = NULL;
out:
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c
index f828e64..c59f36f 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.c
+++ b/drivers/staging/rtl8192u/r8192U_wx.c
@@ -73,11 +73,11 @@ static int r8192_wx_set_rate(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_rate(priv->ieee80211, info, wrqu, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -90,11 +90,11 @@ static int r8192_wx_set_rts(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_rts(priv->ieee80211, info, wrqu, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -115,11 +115,11 @@ static int r8192_wx_set_power(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -139,11 +139,11 @@ static int r8192_wx_force_reset(struct net_device *dev,
{
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

netdev_dbg(dev, "%s(): force reset ! extra is %d\n", __func__, *extra);
priv->force_reset = *extra;
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return 0;

}
@@ -156,11 +156,11 @@ static int r8192_wx_set_rawtx(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;

@@ -174,7 +174,7 @@ static int r8192_wx_set_crcmon(struct net_device *dev,
int *parms = (int *)extra;
int enable = (parms[0] > 0);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

if (enable)
priv->crcmon = 1;
@@ -184,7 +184,7 @@ static int r8192_wx_set_crcmon(struct net_device *dev,
DMESG("bad CRC in monitor mode are %s",
priv->crcmon ? "accepted" : "rejected");

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return 0;
}
@@ -195,13 +195,13 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_mode(priv->ieee80211, a, wrqu, b);

rtl8192_set_rxconf(dev);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

@@ -348,7 +348,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
}
}

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
if (priv->ieee80211->state != IEEE80211_LINKED) {
priv->ieee80211->scanning = 0;
ieee80211_softmac_scan_syncro(priv->ieee80211);
@@ -356,7 +356,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
} else {
ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b);
}
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

@@ -371,11 +371,11 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
if (!priv->up)
return -ENETDOWN;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_get_scan(priv->ieee80211, a, wrqu, b);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -387,11 +387,11 @@ static int r8192_wx_set_essid(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_essid(priv->ieee80211, a, wrqu, b);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -406,11 +406,11 @@ static int r8192_wx_get_essid(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;
}
@@ -422,11 +422,11 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

@@ -483,11 +483,11 @@ static int r8192_wx_set_wap(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
/* struct sockaddr *temp = (struct sockaddr *)awrq; */
- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

ret = ieee80211_wx_set_wap(priv->ieee80211, info, awrq, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return ret;

@@ -532,12 +532,12 @@ static int r8192_wx_set_enc(struct net_device *dev,
if (!priv->up)
return -ENETDOWN;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

RT_TRACE(COMP_SEC, "Setting SW wep key");
ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);



@@ -636,7 +636,7 @@ static int r8192_wx_set_retry(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
int err = 0;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);

if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
wrqu->retry.disabled){
@@ -669,7 +669,7 @@ static int r8192_wx_set_retry(struct net_device *dev,

rtl8192_commit(dev);
exit:
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return err;
}
@@ -720,7 +720,7 @@ static int r8192_wx_set_sens(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
short err = 0;

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
if (priv->rf_set_sens == NULL) {
err = -1; /* we have not this support for this radio */
goto exit;
@@ -731,7 +731,7 @@ static int r8192_wx_set_sens(struct net_device *dev,
err = -EINVAL;

exit:
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);

return err;
}
@@ -746,7 +746,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
struct ieee80211_device *ieee = priv->ieee80211;


- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra);

{
@@ -809,7 +809,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,

end_hw_sec:

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;

}
@@ -820,9 +820,9 @@ static int r8192_wx_set_auth(struct net_device *dev,
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra);
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

@@ -834,10 +834,10 @@ static int r8192_wx_set_mlme(struct net_device *dev,
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra);

- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;
}

@@ -848,9 +848,9 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);

- down(&priv->wx_sem);
+ mutex_lock(&priv->wx_mutex);
ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length);
- up(&priv->wx_sem);
+ mutex_unlock(&priv->wx_mutex);
return ret;


--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project