Commit 07e3a844 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging: rtl8723bs: change pwrctrl lock to a mutex

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: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 09a8ea34
...@@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) ...@@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
if (rtw_btcoex_IsBtControlLps(padapter) == true) if (rtw_btcoex_IsBtControlLps(padapter) == true)
return; return;
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if (pwrpriv->dtim != dtim) { if (pwrpriv->dtim != dtim) {
DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", 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) ...@@ -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)); 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) static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta)
......
...@@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter) ...@@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter)
rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req);
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
_ips_enter(padapter); _ips_enter(padapter);
up(&pwrpriv->lock); mutex_unlock(&pwrpriv->lock);
} }
int _ips_leave(struct adapter *padapter) int _ips_leave(struct adapter *padapter)
...@@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter) ...@@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter)
if (!is_primary_adapter(padapter)) if (!is_primary_adapter(padapter))
return _SUCCESS; return _SUCCESS;
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
ret = _ips_leave(padapter); ret = _ips_leave(padapter);
up(&pwrpriv->lock); mutex_unlock(&pwrpriv->lock);
if (_SUCCESS == ret) if (_SUCCESS == ret)
rtw_btcoex_IpsNotify(padapter, IPS_NONE); rtw_btcoex_IpsNotify(padapter, IPS_NONE);
...@@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter) ...@@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter)
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
u32 ps_deny = 0; u32 ps_deny = 0;
down(&adapter_to_pwrctl(padapter)->lock); mutex_lock(&adapter_to_pwrctl(padapter)->lock);
ps_deny = rtw_ps_deny_get(padapter); ps_deny = rtw_ps_deny_get(padapter);
up(&adapter_to_pwrctl(padapter)->lock); mutex_unlock(&adapter_to_pwrctl(padapter)->lock);
if (ps_deny != 0) { if (ps_deny != 0) {
DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n", DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n",
FUNC_ADPT_ARG(padapter), ps_deny); 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 ...@@ -413,7 +413,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
return; return;
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
/* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */
if (ps_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 ...@@ -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) ...@@ -628,11 +628,11 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
return; return;
} }
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
rtw_set_rpwm(Adapter, PS_STATE_S4); 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); rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0);
} else{ } else{
...@@ -696,7 +696,7 @@ void LPS_Leave_check( ...@@ -696,7 +696,7 @@ void LPS_Leave_check(
cond_resched(); cond_resched();
while (1) { while (1) {
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if ((padapter->bSurpriseRemoved == true) if ((padapter->bSurpriseRemoved == true)
|| (padapter->hw_init_completed == false) || (padapter->hw_init_completed == false)
...@@ -704,7 +704,7 @@ void LPS_Leave_check( ...@@ -704,7 +704,7 @@ void LPS_Leave_check(
) )
bReady = true; bReady = true;
up(&pwrpriv->lock); mutex_unlock(&pwrpriv->lock);
if (true == bReady) if (true == bReady)
break; break;
...@@ -732,11 +732,10 @@ void cpwm_int_hdl( ...@@ -732,11 +732,10 @@ void cpwm_int_hdl(
pwrpriv = adapter_to_pwrctl(padapter); pwrpriv = adapter_to_pwrctl(padapter);
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if (pwrpriv->rpwm < PS_STATE_S2) { if (pwrpriv->rpwm < PS_STATE_S2) {
DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
up(&pwrpriv->lock);
goto exit; goto exit;
} }
...@@ -751,9 +750,9 @@ void cpwm_int_hdl( ...@@ -751,9 +750,9 @@ void cpwm_int_hdl(
complete(&padapter->xmitpriv.xmit_comp); complete(&padapter->xmitpriv.xmit_comp);
} }
up(&pwrpriv->lock);
exit: exit:
mutex_unlock(&pwrpriv->lock);
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm)); ("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm));
} }
...@@ -783,12 +782,12 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) ...@@ -783,12 +782,12 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
padapter = dvobj->if1; padapter = dvobj->if1;
/* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */ /* 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)) { 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); DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
goto exit; goto exit;
} }
up(&pwrpriv->lock); mutex_unlock(&pwrpriv->lock);
if (rtw_read8(padapter, 0x100) != 0xEA) { if (rtw_read8(padapter, 0x100) != 0xEA) {
struct reportpwrstate_parm report; struct reportpwrstate_parm report;
...@@ -800,7 +799,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) ...@@ -800,7 +799,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
return; return;
} }
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm); 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) ...@@ -811,7 +810,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
pwrpriv->brpwmtimeout = false; pwrpriv->brpwmtimeout = false;
exit: exit:
up(&pwrpriv->lock); mutex_unlock(&pwrpriv->lock);
} }
/* /*
...@@ -867,7 +866,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) ...@@ -867,7 +866,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task)
pwrctrl = adapter_to_pwrctl(padapter); pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, task); register_task_alive(pwrctrl, task);
...@@ -884,7 +883,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 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 (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2) if (pwrctrl->cpwm >= PS_STATE_S2)
...@@ -920,7 +919,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) ...@@ -920,7 +919,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
} }
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, task); unregister_task_alive(pwrctrl, task);
...@@ -936,7 +935,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 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) ...@@ -962,7 +961,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter); pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, XMIT_ALIVE); register_task_alive(pwrctrl, XMIT_ALIVE);
...@@ -979,7 +978,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter) ...@@ -979,7 +978,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
} }
} }
up(&pwrctrl->lock); mutex_unlock(&pwrctrl->lock);
if (_FAIL == res) if (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2) if (pwrctrl->cpwm >= PS_STATE_S2)
...@@ -1011,7 +1010,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) ...@@ -1011,7 +1010,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter); pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
register_task_alive(pwrctrl, CMD_ALIVE); register_task_alive(pwrctrl, CMD_ALIVE);
...@@ -1028,7 +1027,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) ...@@ -1028,7 +1027,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
} }
} }
up(&pwrctrl->lock); mutex_unlock(&pwrctrl->lock);
if (_FAIL == res) if (_FAIL == res)
if (pwrctrl->cpwm >= PS_STATE_S2) if (pwrctrl->cpwm >= PS_STATE_S2)
...@@ -1061,7 +1060,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) ...@@ -1061,7 +1060,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
} }
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, XMIT_ALIVE); unregister_task_alive(pwrctrl, XMIT_ALIVE);
...@@ -1076,7 +1075,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) ...@@ -1076,7 +1075,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
rtw_set_rpwm(padapter, pslv); rtw_set_rpwm(padapter, pslv);
} }
up(&pwrctrl->lock); mutex_unlock(&pwrctrl->lock);
} }
/* /*
...@@ -1103,7 +1102,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) ...@@ -1103,7 +1102,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter)
pslv = PS_STATE_S2; pslv = PS_STATE_S2;
} }
down(&pwrctrl->lock); mutex_lock(&pwrctrl->lock);
unregister_task_alive(pwrctrl, CMD_ALIVE); unregister_task_alive(pwrctrl, CMD_ALIVE);
...@@ -1119,14 +1118,14 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) ...@@ -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) void rtw_init_pwrctrl_priv(struct adapter *padapter)
{ {
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(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); sema_init(&pwrctrlpriv->check_32k_lock, 1);
pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0; pwrctrlpriv->ips_enter_cnts = 0;
...@@ -1357,13 +1356,13 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason) ...@@ -1357,13 +1356,13 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason)
pwrpriv = adapter_to_pwrctl(padapter); pwrpriv = adapter_to_pwrctl(padapter);
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if (pwrpriv->ps_deny & BIT(reason)) { if (pwrpriv->ps_deny & BIT(reason)) {
DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n", DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n",
FUNC_ADPT_ARG(padapter), reason); FUNC_ADPT_ARG(padapter), reason);
} }
pwrpriv->ps_deny |= BIT(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", */ /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
...@@ -1383,13 +1382,13 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason) ...@@ -1383,13 +1382,13 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason)
pwrpriv = adapter_to_pwrctl(padapter); pwrpriv = adapter_to_pwrctl(padapter);
down(&pwrpriv->lock); mutex_lock(&pwrpriv->lock);
if ((pwrpriv->ps_deny & BIT(reason)) == 0) { if ((pwrpriv->ps_deny & BIT(reason)) == 0) {
DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n", DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n",
FUNC_ADPT_ARG(padapter), reason); FUNC_ADPT_ARG(padapter), reason);
} }
pwrpriv->ps_deny &= ~BIT(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", */ /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef __RTW_PWRCTRL_H_ #ifndef __RTW_PWRCTRL_H_
#define __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_
#include <linux/mutex.h>
#define FW_PWR0 0 #define FW_PWR0 0
#define FW_PWR1 1 #define FW_PWR1 1
...@@ -207,7 +208,7 @@ typedef struct pno_scan_info ...@@ -207,7 +208,7 @@ typedef struct pno_scan_info
struct pwrctrl_priv struct pwrctrl_priv
{ {
_pwrlock lock; struct mutex lock;
_pwrlock check_32k_lock; _pwrlock check_32k_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 1. read from HCPWM 2. driver lowers power level */ volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment