staging: r8188eu: convert rtw_setdatarate_cmd to correct error semantics
authorPhillip Potter <phil@philpotter.co.uk>
Wed, 2 Nov 2022 00:36:13 +0000 (00:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Nov 2022 07:31:43 +0000 (08:31 +0100)
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: Phillip Potter <phil@philpotter.co.uk>
Link: https://lore.kernel.org/r/20221102003613.971-1-phil@philpotter.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_cmd.c
drivers/staging/r8188eu/include/rtw_cmd.h
drivers/staging/r8188eu/os_dep/ioctl_linux.c

index fdc0c71..19b2f73 100644 (file)
@@ -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)
index a740a9a..c330a44 100644 (file)
@@ -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);
index f3b3d74..dda48a2 100644 (file)
@@ -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 @@ set_rate:
                }
        }
 
-       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,