Commit a3706871 authored by Phillip Potter's avatar Phillip Potter Committed by Greg Kroah-Hartman

staging: r8188eu: convert rtw_setdatarate_cmd to correct error semantics

Convert rtw_setdatarate_cmd function to use proper error return codes
rather than _SUCCESS and _FAIL, and a simpler 'return 0;' style. For now,
wrap rtw_enqueue_cmd call and return -EPERM if it fails, as converting
this function makes more sense later on due to its large number of callers.

Also change rtw_wx_set_rate function to pass through the proper error
code rather than just 0 or -1.
Signed-off-by: default avatarPhillip Potter <phil@philpotter.co.uk>
Link: https://lore.kernel.org/r/20221102003613.971-1-phil@philpotter.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d911a624
......@@ -340,33 +340,29 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
return res;
}
u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
{
struct cmd_obj *ph2c;
struct setdatarate_parm *pbsetdataratepara;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
u8 res = _SUCCESS;
ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC);
if (!ph2c) {
res = _FAIL;
goto exit;
}
if (!ph2c)
return -ENOMEM;
pbsetdataratepara = kzalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC);
if (!pbsetdataratepara) {
kfree(ph2c);
res = _FAIL;
goto exit;
return -ENOMEM;
}
init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate));
pbsetdataratepara->mac_id = 5;
memcpy(pbsetdataratepara->datarates, rateset, NumRates);
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
exit:
if (rtw_enqueue_cmd(pcmdpriv, ph2c) == _FAIL)
return -EPERM;
return res;
return 0;
}
void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
......
......@@ -727,7 +727,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue)
u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype);
u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode);
u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval);
......
......@@ -1340,7 +1340,7 @@ static int rtw_wx_set_rate(struct net_device *dev,
struct iw_request_info *a,
union iwreq_data *wrqu, char *extra)
{
int i, ret = 0;
int i;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 datarates[NumRates];
u32 target_rate = wrqu->bitrate.value;
......@@ -1408,10 +1408,7 @@ static int rtw_wx_set_rate(struct net_device *dev,
}
}
if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS)
ret = -1;
return ret;
return rtw_setdatarate_cmd(padapter, datarates);
}
static int rtw_wx_get_rate(struct net_device *dev,
......
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