mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics
Convert the rtw_pwr_wakeup function to use 0 on success and an appropriate error code on error. For the first failure block where ips_leave is invoked, use -ENOMEM as this is the main cause of failure here anyway. For the second failure block, use -EBUSY, as it seems the most appropriate. Finally, within the functions rtw_wx_set_mode, rtw_wx_set_wap, rtw_wx_set_scan and rtw_wx_set_essid, pass the error code on from rtw_pwr_wakeup as appropriate now that it is converted. This gets the driver closer to removal of the non-standard _SUCCESS and _FAIL definitions, which are inverted compared to the standard in-kernel error code mechanism. Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150 Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Phillip Potter <phil@philpotter.co.uk> Link: https://lore.kernel.org/r/20220725220745.12739-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4709238102
commit
2b5002e2cc
3 changed files with 15 additions and 23 deletions
|
@ -1888,7 +1888,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
|
||||||
|
|
||||||
if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) {
|
if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) {
|
||||||
/* leave IPS/Autosuspend */
|
/* leave IPS/Autosuspend */
|
||||||
if (rtw_pwr_wakeup(padapter) == _FAIL) {
|
if (rtw_pwr_wakeup(padapter)) {
|
||||||
ret = _FAIL;
|
ret = _FAIL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1902,7 +1902,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
|
||||||
init_wifidirect_info(padapter, role);
|
init_wifidirect_info(padapter, role);
|
||||||
|
|
||||||
} else if (role == P2P_ROLE_DISABLE) {
|
} else if (role == P2P_ROLE_DISABLE) {
|
||||||
if (rtw_pwr_wakeup(padapter) == _FAIL) {
|
if (rtw_pwr_wakeup(padapter)) {
|
||||||
ret = _FAIL;
|
ret = _FAIL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,24 +381,24 @@ int rtw_pwr_wakeup(struct adapter *padapter)
|
||||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||||
unsigned long timeout = jiffies + msecs_to_jiffies(3000);
|
unsigned long timeout = jiffies + msecs_to_jiffies(3000);
|
||||||
unsigned long deny_time;
|
unsigned long deny_time;
|
||||||
int ret = _SUCCESS;
|
int ret = 0;
|
||||||
|
|
||||||
while (pwrpriv->ps_processing && time_before(jiffies, timeout))
|
while (pwrpriv->ps_processing && time_before(jiffies, timeout))
|
||||||
msleep(10);
|
msleep(10);
|
||||||
|
|
||||||
/* I think this should be check in IPS, LPS, autosuspend functions... */
|
/* I think this should be check in IPS, LPS, autosuspend functions... */
|
||||||
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
||||||
ret = _SUCCESS;
|
ret = 0;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pwrpriv->rf_pwrstate == rf_off && ips_leave(padapter) == _FAIL) {
|
if (pwrpriv->rf_pwrstate == rf_off && ips_leave(padapter) == _FAIL) {
|
||||||
ret = _FAIL;
|
ret = -ENOMEM;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) {
|
if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) {
|
||||||
ret = _FAIL;
|
ret = -EBUSY;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
|
||||||
return 0;
|
return 0;
|
||||||
} else if (mode == IPS_NONE) {
|
} else if (mode == IPS_NONE) {
|
||||||
rtw_ips_mode_req(pwrctrlpriv, mode);
|
rtw_ips_mode_req(pwrctrlpriv, mode);
|
||||||
if ((padapter->bSurpriseRemoved == 0) && (rtw_pwr_wakeup(padapter) == _FAIL))
|
if ((padapter->bSurpriseRemoved == 0) && rtw_pwr_wakeup(padapter))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
} else {
|
} else {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -687,12 +687,9 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
|
||||||
enum ndis_802_11_network_infra networkType;
|
enum ndis_802_11_network_infra networkType;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
ret = rtw_pwr_wakeup(padapter);
|
||||||
|
if (ret)
|
||||||
if (_FAIL == rtw_pwr_wakeup(padapter)) {
|
|
||||||
ret = -EPERM;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (!padapter->hw_init_completed) {
|
if (!padapter->hw_init_completed) {
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
|
@ -931,12 +928,9 @@ static int rtw_wx_set_wap(struct net_device *dev,
|
||||||
struct wlan_network *pnetwork = NULL;
|
struct wlan_network *pnetwork = NULL;
|
||||||
enum ndis_802_11_auth_mode authmode;
|
enum ndis_802_11_auth_mode authmode;
|
||||||
|
|
||||||
|
ret = rtw_pwr_wakeup(padapter);
|
||||||
|
if (ret)
|
||||||
if (_FAIL == rtw_pwr_wakeup(padapter)) {
|
|
||||||
ret = -1;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (!padapter->bup) {
|
if (!padapter->bup) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -1049,10 +1043,9 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
|
||||||
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
|
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
|
||||||
struct wifidirect_info *pwdinfo = &padapter->wdinfo;
|
struct wifidirect_info *pwdinfo = &padapter->wdinfo;
|
||||||
|
|
||||||
if (_FAIL == rtw_pwr_wakeup(padapter)) {
|
ret = rtw_pwr_wakeup(padapter);
|
||||||
ret = -1;
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (padapter->bDriverStopped) {
|
if (padapter->bDriverStopped) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -1252,10 +1245,9 @@ static int rtw_wx_set_essid(struct net_device *dev,
|
||||||
|
|
||||||
uint ret = 0, len;
|
uint ret = 0, len;
|
||||||
|
|
||||||
if (_FAIL == rtw_pwr_wakeup(padapter)) {
|
ret = rtw_pwr_wakeup(padapter);
|
||||||
ret = -1;
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
|
||||||
|
|
||||||
if (!padapter->bup) {
|
if (!padapter->bup) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
Loading…
Reference in a new issue