mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 15:42:46 +00:00
rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
The semaphore 'lock' in pwrctrl_priv is a simple mutex, so it should be written as one. Semaphores are going away in the future. _enter_pwrlock was using down_interruptible(), so the lock could be broken by sending a signal. This could be a bug, because nothing checks the return code here. Hence, using mutex_lock instead of the interruptible version. Also, remove the now unused wrappers _init_pwrlock, _enter_pwrlock, _exit_pwrlock and _rtw_down_sema. Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
16677cca77
commit
f18c566e4e
6 changed files with 17 additions and 39 deletions
|
@ -38,7 +38,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
|
||||||
LeaveAllPowerSaveMode(padapter);
|
LeaveAllPowerSaveMode(padapter);
|
||||||
|
|
||||||
DBG_88E("==> rtw_hw_suspend\n");
|
DBG_88E("==> rtw_hw_suspend\n");
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
pwrpriv->bips_processing = true;
|
pwrpriv->bips_processing = true;
|
||||||
/* s1. */
|
/* s1. */
|
||||||
if (pnetdev) {
|
if (pnetdev) {
|
||||||
|
@ -73,7 +73,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
|
||||||
pwrpriv->rf_pwrstate = rf_off;
|
pwrpriv->rf_pwrstate = rf_off;
|
||||||
pwrpriv->bips_processing = false;
|
pwrpriv->bips_processing = false;
|
||||||
|
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ static int rtw_hw_resume(struct adapter *padapter)
|
||||||
|
|
||||||
/* system resume */
|
/* system resume */
|
||||||
DBG_88E("==> rtw_hw_resume\n");
|
DBG_88E("==> rtw_hw_resume\n");
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
pwrpriv->bips_processing = true;
|
pwrpriv->bips_processing = true;
|
||||||
rtw_reset_drv_sw(padapter);
|
rtw_reset_drv_sw(padapter);
|
||||||
|
|
||||||
if (pm_netdev_open(pnetdev, false) != 0) {
|
if (pm_netdev_open(pnetdev, false) != 0) {
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ static int rtw_hw_resume(struct adapter *padapter)
|
||||||
pwrpriv->rf_pwrstate = rf_on;
|
pwrpriv->rf_pwrstate = rf_on;
|
||||||
pwrpriv->bips_processing = false;
|
pwrpriv->bips_processing = false;
|
||||||
|
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -138,7 +138,7 @@ void ips_enter(struct adapter *padapter)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
pwrpriv->bips_processing = true;
|
pwrpriv->bips_processing = true;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void ips_enter(struct adapter *padapter)
|
||||||
}
|
}
|
||||||
pwrpriv->bips_processing = false;
|
pwrpriv->bips_processing = false;
|
||||||
|
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ips_leave(struct adapter *padapter)
|
int ips_leave(struct adapter *padapter)
|
||||||
|
@ -171,7 +171,7 @@ int ips_leave(struct adapter *padapter)
|
||||||
int keyid;
|
int keyid;
|
||||||
|
|
||||||
|
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
|
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
|
||||||
pwrpriv->bips_processing = true;
|
pwrpriv->bips_processing = true;
|
||||||
|
@ -205,7 +205,7 @@ int ips_leave(struct adapter *padapter)
|
||||||
pwrpriv->bpower_saving = false;
|
pwrpriv->bpower_saving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
|
||||||
{
|
{
|
||||||
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
||||||
|
|
||||||
_init_pwrlock(&pwrctrlpriv->lock);
|
mutex_init(&pwrctrlpriv->mutex_lock);
|
||||||
pwrctrlpriv->rf_pwrstate = rf_on;
|
pwrctrlpriv->rf_pwrstate = rf_on;
|
||||||
pwrctrlpriv->ips_enter_cnts = 0;
|
pwrctrlpriv->ips_enter_cnts = 0;
|
||||||
pwrctrlpriv->ips_leave_cnts = 0;
|
pwrctrlpriv->ips_leave_cnts = 0;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <linux/atomic.h>
|
#include <linux/atomic.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/semaphore.h>
|
#include <linux/semaphore.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
#include <linux/sem.h>
|
#include <linux/sem.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
|
@ -78,8 +79,6 @@ u8 *_rtw_malloc(u32 sz);
|
||||||
|
|
||||||
void *rtw_malloc2d(int h, int w, int size);
|
void *rtw_malloc2d(int h, int w, int size);
|
||||||
|
|
||||||
u32 _rtw_down_sema(struct semaphore *sema);
|
|
||||||
|
|
||||||
void _rtw_init_queue(struct __queue *pqueue);
|
void _rtw_init_queue(struct __queue *pqueue);
|
||||||
|
|
||||||
struct rtw_netdev_priv_indicator {
|
struct rtw_netdev_priv_indicator {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <wlan_bssdef.h>
|
#include <wlan_bssdef.h>
|
||||||
#include <linux/semaphore.h>
|
#include <linux/semaphore.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
#include <linux/sem.h>
|
#include <linux/sem.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -92,21 +92,6 @@ struct reportpwrstate_parm {
|
||||||
unsigned short rsvd;
|
unsigned short rsvd;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void _init_pwrlock(struct semaphore *plock)
|
|
||||||
{
|
|
||||||
sema_init(plock, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void _enter_pwrlock(struct semaphore *plock)
|
|
||||||
{
|
|
||||||
_rtw_down_sema(plock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void _exit_pwrlock(struct semaphore *plock)
|
|
||||||
{
|
|
||||||
up(plock);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
|
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
|
||||||
|
|
||||||
#define EXE_PWR_NONE 0x01
|
#define EXE_PWR_NONE 0x01
|
||||||
|
@ -157,7 +142,7 @@ enum { /* for ips_mode */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pwrctrl_priv {
|
struct pwrctrl_priv {
|
||||||
struct semaphore lock;
|
struct mutex mutex_lock;
|
||||||
volatile u8 rpwm; /* requested power state for fw */
|
volatile u8 rpwm; /* requested power state for fw */
|
||||||
volatile u8 cpwm; /* fw current power state. updated when
|
volatile u8 cpwm; /* fw current power state. updated when
|
||||||
* 1. read from HCPWM 2. driver lowers power level */
|
* 1. read from HCPWM 2. driver lowers power level */
|
||||||
|
|
|
@ -55,13 +55,6 @@ void *rtw_malloc2d(int h, int w, int size)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 _rtw_down_sema(struct semaphore *sema)
|
|
||||||
{
|
|
||||||
if (down_interruptible(sema))
|
|
||||||
return _FAIL;
|
|
||||||
return _SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _rtw_init_queue(struct __queue *pqueue)
|
void _rtw_init_queue(struct __queue *pqueue)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&(pqueue->queue));
|
INIT_LIST_HEAD(&(pqueue->queue));
|
||||||
|
|
|
@ -238,7 +238,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
|
||||||
rtw_cancel_all_timer(padapter);
|
rtw_cancel_all_timer(padapter);
|
||||||
LeaveAllPowerSaveMode(padapter);
|
LeaveAllPowerSaveMode(padapter);
|
||||||
|
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
/* s1. */
|
/* s1. */
|
||||||
if (pnetdev) {
|
if (pnetdev) {
|
||||||
netif_carrier_off(pnetdev);
|
netif_carrier_off(pnetdev);
|
||||||
|
@ -267,7 +267,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
|
||||||
rtw_free_network_queue(padapter, true);
|
rtw_free_network_queue(padapter, true);
|
||||||
|
|
||||||
rtw_dev_unload(padapter);
|
rtw_dev_unload(padapter);
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
|
||||||
rtw_indicate_scan_done(padapter, 1);
|
rtw_indicate_scan_done(padapter, 1);
|
||||||
|
@ -298,7 +298,7 @@ static int rtw_resume_process(struct adapter *padapter)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
_enter_pwrlock(&pwrpriv->lock);
|
mutex_lock(&pwrpriv->mutex_lock);
|
||||||
rtw_reset_drv_sw(padapter);
|
rtw_reset_drv_sw(padapter);
|
||||||
pwrpriv->bkeepfwalive = false;
|
pwrpriv->bkeepfwalive = false;
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ static int rtw_resume_process(struct adapter *padapter)
|
||||||
netif_device_attach(pnetdev);
|
netif_device_attach(pnetdev);
|
||||||
netif_carrier_on(pnetdev);
|
netif_carrier_on(pnetdev);
|
||||||
|
|
||||||
_exit_pwrlock(&pwrpriv->lock);
|
mutex_unlock(&pwrpriv->mutex_lock);
|
||||||
|
|
||||||
rtw_roaming(padapter, NULL);
|
rtw_roaming(padapter, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue