[PATCH 2/3] staging: rtl8723bs: change pwrctrl lock to a mutex
From: Arnd Bergmann
Date: Mon Dec 10 2018 - 16:42:17 EST
This semaphore is used like a mutex, so it should use the regular
mutex API, as we do in the other copies of this driver.
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 +-
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 73 +++++++++----------
.../staging/rtl8723bs/include/rtw_pwrctrl.h | 3 +-
3 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 3d206c33eafa..984db6f2217c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
if (rtw_btcoex_IsBtControlLps(padapter) == true)
return;
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if (pwrpriv->dtim != dtim) {
DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", pwrpriv->dtim, dtim,
@@ -1638,7 +1638,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
}
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
}
static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta)
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index a0d8fbeecf9b..b7dd5fec9b31 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter)
rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req);
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
_ips_enter(padapter);
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
}
int _ips_leave(struct adapter *padapter)
@@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter)
if (!is_primary_adapter(padapter))
return _SUCCESS;
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
ret = _ips_leave(padapter);
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
if (_SUCCESS == ret)
rtw_btcoex_IpsNotify(padapter, IPS_NONE);
@@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter)
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
u32 ps_deny = 0;
- down(&adapter_to_pwrctl(padapter)->lock);
+ mutex_lock(&adapter_to_pwrctl(padapter)->lock);
ps_deny = rtw_ps_deny_get(padapter);
- up(&adapter_to_pwrctl(padapter)->lock);
+ mutex_unlock(&adapter_to_pwrctl(padapter)->lock);
if (ps_deny != 0) {
DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n",
FUNC_ADPT_ARG(padapter), ps_deny);
@@ -413,7 +413,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
return;
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
/* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */
if (ps_mode == PS_MODE_ACTIVE) {
@@ -494,7 +494,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
}
}
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
}
/*
@@ -628,11 +628,11 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
return;
}
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
rtw_set_rpwm(Adapter, PS_STATE_S4);
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0);
} else{
@@ -696,7 +696,7 @@ void LPS_Leave_check(
cond_resched();
while (1) {
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if ((padapter->bSurpriseRemoved == true)
|| (padapter->hw_init_completed == false)
@@ -704,7 +704,7 @@ void LPS_Leave_check(
)
bReady = true;
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
if (true == bReady)
break;
@@ -732,11 +732,10 @@ void cpwm_int_hdl(
pwrpriv = adapter_to_pwrctl(padapter);
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if (pwrpriv->rpwm < PS_STATE_S2) {
DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
- up(&pwrpriv->lock);
goto exit;
}
@@ -751,9 +750,9 @@ void cpwm_int_hdl(
complete(&padapter->xmitpriv.xmit_comp);
}
- up(&pwrpriv->lock);
-
exit:
+ mutex_unlock(&pwrpriv->lock);
+
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm));
}
@@ -783,12 +782,12 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
padapter = dvobj->if1;
/* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
goto exit;
}
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
if (rtw_read8(padapter, 0x100) != 0xEA) {
struct reportpwrstate_parm report;
@@ -800,7 +799,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
return;
}
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm);
@@ -811,7 +810,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
pwrpriv->brpwmtimeout = false;
exit:
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
}
/*
@@ -867,7 +866,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2;
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, task);
@@ -884,7 +883,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task)
}
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
if (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2)
@@ -920,7 +919,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)
pslv = PS_STATE_S2;
}
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, task);
@@ -936,7 +935,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
}
/*
@@ -962,7 +961,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2;
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, XMIT_ALIVE);
@@ -979,7 +978,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
}
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
if (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2)
@@ -1011,7 +1010,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2;
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, CMD_ALIVE);
@@ -1028,7 +1027,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
}
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
if (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2)
@@ -1061,7 +1060,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
pslv = PS_STATE_S2;
}
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, XMIT_ALIVE);
@@ -1076,7 +1075,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
rtw_set_rpwm(padapter, pslv);
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
}
/*
@@ -1103,7 +1102,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter)
pslv = PS_STATE_S2;
}
- down(&pwrctrl->lock);
+ mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, CMD_ALIVE);
@@ -1119,14 +1118,14 @@ void rtw_unregister_cmd_alive(struct adapter *padapter)
}
}
- up(&pwrctrl->lock);
+ mutex_unlock(&pwrctrl->lock);
}
void rtw_init_pwrctrl_priv(struct adapter *padapter)
{
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
- sema_init(&pwrctrlpriv->lock, 1);
+ mutex_init(&pwrctrlpriv->lock);
sema_init(&pwrctrlpriv->check_32k_lock, 1);
pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0;
@@ -1357,13 +1356,13 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason)
pwrpriv = adapter_to_pwrctl(padapter);
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if (pwrpriv->ps_deny & BIT(reason)) {
DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n",
FUNC_ADPT_ARG(padapter), reason);
}
pwrpriv->ps_deny |= BIT(reason);
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
@@ -1383,13 +1382,13 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason)
pwrpriv = adapter_to_pwrctl(padapter);
- down(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->lock);
if ((pwrpriv->ps_deny & BIT(reason)) == 0) {
DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n",
FUNC_ADPT_ARG(padapter), reason);
}
pwrpriv->ps_deny &= ~BIT(reason);
- up(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->lock);
/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
index 72df6cffe62e..abf48ae01900 100644
--- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
@@ -7,6 +7,7 @@
#ifndef __RTW_PWRCTRL_H_
#define __RTW_PWRCTRL_H_
+#include <linux/mutex.h>
#define FW_PWR0 0
#define FW_PWR1 1
@@ -207,7 +208,7 @@ typedef struct pno_scan_info
struct pwrctrl_priv
{
- _pwrlock lock;
+ struct mutex lock;
_pwrlock check_32k_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 */
--
2.20.0