linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex ***
@ 2016-06-08  7:40 Binoy Jayan
  2016-06-08  7:40 ` [PATCH 1/2] staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex Binoy Jayan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Larry Finger, Jes Sorensen
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, linux-wireless,
	Binoy Jayan

Hi,

These are a set of patches which removes semaphores from:

drivers/staging/rtl8723au

These are part of a bigger effort to eliminate all semaphores 
from the linux kernel.

They build correctly (individually and as a whole).
NB: I have not tested this as I do not have the following hardware:

R8723AU
"Realtek RTL8723AU Wireless LAN NIC driver"

Thanks,
Binoy

Binoy Jayan (2):
  staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex
  staging: r8723au: Remove unused semaphores

 drivers/staging/rtl8723au/core/rtw_pwrctrl.c      | 11 ++++++-----
 drivers/staging/rtl8723au/core/rtw_xmit.c         |  4 ----
 drivers/staging/rtl8723au/include/osdep_service.h |  1 -
 drivers/staging/rtl8723au/include/rtw_io.h        |  2 --
 drivers/staging/rtl8723au/include/rtw_pwrctrl.h   |  3 ++-
 drivers/staging/rtl8723au/include/rtw_xmit.h      |  5 -----
 drivers/staging/rtl8723au/os_dep/usb_intf.c       | 11 ++++++-----
 7 files changed, 14 insertions(+), 23 deletions(-)

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex
  2016-06-08  7:40 [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Binoy Jayan
@ 2016-06-08  7:40 ` Binoy Jayan
  2016-06-08  7:40 ` [PATCH 2/2] staging: r8723au: Remove unused semaphores Binoy Jayan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Larry Finger, Jes Sorensen
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, linux-wireless,
	Binoy Jayan

The semaphore 'lock' in pwrctrl_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@linaro.org>
---
 drivers/staging/rtl8723au/core/rtw_pwrctrl.c    | 11 ++++++-----
 drivers/staging/rtl8723au/include/rtw_pwrctrl.h |  3 ++-
 drivers/staging/rtl8723au/os_dep/usb_intf.c     | 11 ++++++-----
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
index 7488a10..2d43958 100644
--- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
@@ -14,6 +14,7 @@
  ******************************************************************************/
 #define _RTW_PWRCTRL_C_
 
+#include <linux/mutex.h>
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <osdep_intf.h>
@@ -27,7 +28,7 @@ void ips_enter23a(struct rtw_adapter *padapter)
 {
 	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
 
-	down(&pwrpriv->lock);
+	mutex_lock(&pwrpriv->mutex_lock);
 
 	pwrpriv->bips_processing = true;
 
@@ -50,7 +51,7 @@ void ips_enter23a(struct rtw_adapter *padapter)
 	}
 	pwrpriv->bips_processing = false;
 
-	up(&pwrpriv->lock);
+	mutex_unlock(&pwrpriv->mutex_lock);
 }
 
 int ips_leave23a(struct rtw_adapter *padapter)
@@ -61,7 +62,7 @@ int ips_leave23a(struct rtw_adapter *padapter)
 	int result = _SUCCESS;
 	int keyid;
 
-	down(&pwrpriv->lock);
+	mutex_lock(&pwrpriv->mutex_lock);
 
 	if (pwrpriv->rf_pwrstate == rf_off && !pwrpriv->bips_processing) {
 		pwrpriv->bips_processing = true;
@@ -106,7 +107,7 @@ int ips_leave23a(struct rtw_adapter *padapter)
 		pwrpriv->bpower_saving = false;
 	}
 
-	up(&pwrpriv->lock);
+	mutex_unlock(&pwrpriv->mutex_lock);
 
 	return result;
 }
@@ -423,7 +424,7 @@ void rtw_init_pwrctrl_priv23a(struct rtw_adapter *padapter)
 {
 	struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
 
-	sema_init(&pwrctrlpriv->lock, 1);
+	mutex_init(&pwrctrlpriv->mutex_lock);
 	pwrctrlpriv->rf_pwrstate = rf_on;
 	pwrctrlpriv->ips_enter23a_cnts = 0;
 	pwrctrlpriv->ips_leave23a_cnts = 0;
diff --git a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
index 599fed9..699b9f3 100644
--- a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
@@ -15,6 +15,7 @@
 #ifndef __RTW_PWRCTRL_H_
 #define __RTW_PWRCTRL_H_
 
+#include <linux/mutex.h>
 #include <osdep_service.h>
 #include <drv_types.h>
 
@@ -149,7 +150,7 @@ enum { /*  for ips_mode */
 };
 
 struct pwrctrl_priv {
-	struct semaphore lock;
+	struct mutex mutex_lock;
 	volatile u8 rpwm; /* requested power state for fw */
 	volatile u8 cpwm; /* fw current power state. updated when 1.
 			   * read from HCPWM 2. driver lowers power level
diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c
index cf83eff..fa7dda5 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c
@@ -14,6 +14,7 @@
  ******************************************************************************/
 #define _HCI_INTF_C_
 
+#include <linux/mutex.h>
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <recv_osdep.h>
@@ -291,7 +292,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
 	rtw_cancel_all_timer23a(padapter);
 	LeaveAllPowerSaveMode23a(padapter);
 
-	down(&pwrpriv->lock);
+	mutex_lock(&pwrpriv->mutex_lock);
 	/* padapter->net_closed = true; */
 	/* s1. */
 	if (pnetdev) {
@@ -321,7 +322,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
 	rtw_free_network_queue23a(padapter);
 
 	rtw_dev_unload(padapter);
-	up(&pwrpriv->lock);
+	mutex_unlock(&pwrpriv->mutex_lock);
 
 	if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
 		rtw_cfg80211_indicate_scan_done(
@@ -353,20 +354,20 @@ static int rtw_resume(struct usb_interface *pusb_intf)
 	pnetdev = padapter->pnetdev;
 	pwrpriv = &padapter->pwrctrlpriv;
 
-	down(&pwrpriv->lock);
+	mutex_lock(&pwrpriv->mutex_lock);
 	rtw_reset_drv_sw23a(padapter);
 	pwrpriv->bkeepfwalive = false;
 
 	DBG_8723A("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
 	if (pm_netdev_open23a(pnetdev, true) != 0) {
-		up(&pwrpriv->lock);
+		mutex_unlock(&pwrpriv->mutex_lock);
 		goto exit;
 	}
 
 	netif_device_attach(pnetdev);
 	netif_carrier_on(pnetdev);
 
-	up(&pwrpriv->lock);
+	mutex_unlock(&pwrpriv->mutex_lock);
 
 	if (padapter->pid[1] != 0) {
 		DBG_8723A("pid[1]:%d\n", padapter->pid[1]);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] staging: r8723au: Remove unused semaphores
  2016-06-08  7:40 [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Binoy Jayan
  2016-06-08  7:40 ` [PATCH 1/2] staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex Binoy Jayan
@ 2016-06-08  7:40 ` Binoy Jayan
  2016-06-08 12:21 ` [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Jes Sorensen
  2016-06-08 15:38 ` Arnd Bergmann
  3 siblings, 0 replies; 5+ messages in thread
From: Binoy Jayan @ 2016-06-08  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Larry Finger, Jes Sorensen
  Cc: Arnd Bergmann, driverdev-devel, linux-kernel, linux-wireless,
	Binoy Jayan

The semaphores xmit_sema, terminate_xmitthread_sema, tx_retevt and
io_req have no users, hence remove all references to them.
Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/staging/rtl8723au/core/rtw_xmit.c         | 4 ----
 drivers/staging/rtl8723au/include/osdep_service.h | 1 -
 drivers/staging/rtl8723au/include/rtw_io.h        | 2 --
 drivers/staging/rtl8723au/include/rtw_xmit.h      | 5 -----
 4 files changed, 12 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index 3de40cf..003576d 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -60,8 +60,6 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 
 	spin_lock_init(&pxmitpriv->lock);
 	spin_lock_init(&pxmitpriv->lock_sctx);
-	sema_init(&pxmitpriv->xmit_sema, 0);
-	sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
 
 	pxmitpriv->adapter = padapter;
 
@@ -177,8 +175,6 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 	for (i = 0; i < 4; i ++)
 		pxmitpriv->wmm_para_seq[i] = i;
 
-	sema_init(&pxmitpriv->tx_retevt, 0);
-
 	pxmitpriv->ack_tx = false;
 	mutex_init(&pxmitpriv->ack_tx_mutex);
 	rtw_sctx_init23a(&pxmitpriv->ack_tx_ops, 0);
diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h
index 98250b1..33ecb9c 100644
--- a/drivers/staging/rtl8723au/include/osdep_service.h
+++ b/drivers/staging/rtl8723au/include/osdep_service.h
@@ -33,7 +33,6 @@
 #include <asm/byteorder.h>
 #include <linux/atomic.h>
 #include <linux/io.h>
-#include <linux/semaphore.h>
 #include <linux/sem.h>
 #include <linux/sched.h>
 #include <linux/etherdevice.h>
diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h
index c8119e2..d875e9e 100644
--- a/drivers/staging/rtl8723au/include/rtw_io.h
+++ b/drivers/staging/rtl8723au/include/rtw_io.h
@@ -20,7 +20,6 @@
 #include <osdep_intf.h>
 
 #include <asm/byteorder.h>
-#include <linux/semaphore.h>
 #include <linux/list.h>
 /* include <linux/smp_lock.h> */
 #include <linux/spinlock.h>
@@ -105,7 +104,6 @@ struct io_req {
 	u32	command;
 	u32	status;
 	u8	*pbuf;
-	struct semaphore	sema;
 
 	void (*_async_io_callback)(struct rtw_adapter *padater, struct io_req *pio_req, u8 *cnxt);
 	u8 *cnxt;
diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h
index 2b7d6d0..24f326b 100644
--- a/drivers/staging/rtl8723au/include/rtw_xmit.h
+++ b/drivers/staging/rtl8723au/include/rtw_xmit.h
@@ -275,9 +275,6 @@ struct agg_pkt_info {
 struct	xmit_priv {
 	spinlock_t	lock;
 
-	struct semaphore	xmit_sema;
-	struct semaphore	terminate_xmitthread_sema;
-
 	struct rtw_queue	be_pending;
 	struct rtw_queue	bk_pending;
 	struct rtw_queue	vi_pending;
@@ -310,8 +307,6 @@ struct	xmit_priv {
 				 * 2->be, 3->bk.
 				 */
 
-	struct semaphore	tx_retevt;/* all tx return event; */
-
 	struct tasklet_struct xmit_tasklet;
 
 	struct rtw_queue free_xmitbuf_queue;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex ***
  2016-06-08  7:40 [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Binoy Jayan
  2016-06-08  7:40 ` [PATCH 1/2] staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex Binoy Jayan
  2016-06-08  7:40 ` [PATCH 2/2] staging: r8723au: Remove unused semaphores Binoy Jayan
@ 2016-06-08 12:21 ` Jes Sorensen
  2016-06-08 15:38 ` Arnd Bergmann
  3 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2016-06-08 12:21 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Greg Kroah-Hartman, Larry Finger, Arnd Bergmann, driverdev-devel,
	linux-kernel, linux-wireless

Binoy Jayan <binoy.jayan@linaro.org> writes:
> Hi,
>
> These are a set of patches which removes semaphores from:
>
> drivers/staging/rtl8723au
>
> These are part of a bigger effort to eliminate all semaphores 
> from the linux kernel.
>
> They build correctly (individually and as a whole).
> NB: I have not tested this as I do not have the following hardware:
>
> R8723AU
> "Realtek RTL8723AU Wireless LAN NIC driver"

I am not against this, but please note this driver is already marked for
deletion in a future kernel release.

Cheers,
Jes

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex ***
  2016-06-08  7:40 [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Binoy Jayan
                   ` (2 preceding siblings ...)
  2016-06-08 12:21 ` [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Jes Sorensen
@ 2016-06-08 15:38 ` Arnd Bergmann
  3 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-06-08 15:38 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Greg Kroah-Hartman, Larry Finger, Jes Sorensen, driverdev-devel,
	linux-kernel, linux-wireless

On Wednesday, June 8, 2016 1:10:53 PM CEST Binoy Jayan wrote:
> These are a set of patches which removes semaphores from:
> 
> drivers/staging/rtl8723au
> 
> These are part of a bigger effort to eliminate all semaphores 
> from the linux kernel.
> 
> They build correctly (individually and as a whole).

Looks good,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-08 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08  7:40 [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Binoy Jayan
2016-06-08  7:40 ` [PATCH 1/2] staging: r8723au: pwrctrl_priv: Replace semaphore lock with mutex Binoy Jayan
2016-06-08  7:40 ` [PATCH 2/2] staging: r8723au: Remove unused semaphores Binoy Jayan
2016-06-08 12:21 ` [PATCH 0/2] *** r8723au: Replace semaphore lock with mutex *** Jes Sorensen
2016-06-08 15:38 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).