Skip to contentSkip to conversation

staging: r8188eu: convert rtw_p2p_enable to correct error code semantics

PATCH In review Phillip Potter 3 participants 5 messages Aug 2, 2022 – Aug 4, 2022 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: convert rtw_p2p_enable to correct error code semantics

Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable.

This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear.

This change moves the driver slowly closer to using standard error code semantics everywhere.

---
 drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
 2 files changed, 13 insertions(+), 18 deletions(-)
drivers/staging/r8188eu/core/rtw_p2p.c +8 -11
index bd654d4ff8b4..dc159e58f428 100644
@@ -1883,15 +1883,14 @@ void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role)
 
 int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
 {
-	int ret = _SUCCESS;
+	int ret;
 	struct wifidirect_info *pwdinfo = &padapter->wdinfo;
 
 	if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) {
 		/* leave IPS/Autosuspend */
-		if (rtw_pwr_wakeup(padapter)) {
-			ret = _FAIL;
-			goto exit;
-		}
+		ret = rtw_pwr_wakeup(padapter);
+		if (ret)
+			return ret;
 
 		/*	Added by Albert 2011/03/22 */
 		/*	In the P2P mode, the driver should not support the b mode. */
@@ -1902,10 +1901,9 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
 		init_wifidirect_info(padapter, role);
 
 	} else if (role == P2P_ROLE_DISABLE) {
-		if (rtw_pwr_wakeup(padapter)) {
-			ret = _FAIL;
-			goto exit;
-		}
+		ret = rtw_pwr_wakeup(padapter);
+		if (ret)
+			return ret;
 
 		/* Disable P2P function */
 		if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
@@ -1923,6 +1921,5 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
 		update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode);
 	}
 
-exit:
-	return ret;
+	return 0;
 }
drivers/staging/r8188eu/os_dep/ioctl_linux.c +5 -7
index 7f91dac2e41b..e9802d42aa1b 100644
@@ -2079,7 +2079,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev,
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	int ret = 0;
+	int ret;
 	struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
 	struct wifidirect_info *pwdinfo = &padapter->wdinfo;
 	struct mlme_ext_priv	*pmlmeext = &padapter->mlmeextpriv;
@@ -2094,10 +2094,9 @@ static int rtw_wext_p2p_enable(struct net_device *dev,
 	else if (*extra == '3')
 		init_role = P2P_ROLE_GO;
 
-	if (_FAIL == rtw_p2p_enable(padapter, init_role)) {
-		ret = -EFAULT;
-		goto exit;
-	}
+	ret = rtw_p2p_enable(padapter, init_role);
+	if (ret)
+		return ret;
 
 	/* set channel/bandwidth */
 	if (init_role != P2P_ROLE_DISABLE) {
@@ -2121,8 +2120,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev,
 		set_channel_bwmode(padapter, channel, ch_offset, bwmode);
 	}
 
-exit:
-	return ret;
+	return 0;
 }
 
 static void rtw_p2p_set_go_nego_ssid(struct net_device *dev,
Signature · 1 line
2.37.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Phillip Potter

Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable.

This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear.

Quoted 4 lines

This change moves the driver slowly closer to using standard error code semantics everywhere.

Looks good. Thanks!

regards,
dan carpenter

#2 lore raw
Quoted 15 lines · Dan Carpenter
Quoted 14 lines · Phillip Potter

Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable.

This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear.

This change moves the driver slowly closer to using standard error code semantics everywhere.

Quoted 9 lines
Quoted 1 line

Looks good. Thanks!

regards,
dan carpenter

Thanks for the review Dan, much appreciated.

Regards,
Phil

Tested-by on v1 1/1
#3 lore raw
In reply to Phillip Potter
Quoted 11 lines · Phillip Potter

Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable.

This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear.

Quoted 8 lines

This change moves the driver slowly closer to using standard error code semantics everywhere.

---
  drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
  2 files changed, 13 insertions(+), 18 deletions(-)
#4 lore raw
Quoted 15 lines · Philipp Hortmann
Quoted 14 lines · Phillip Potter

Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable.

This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear.

This change moves the driver slowly closer to using standard error code semantics everywhere.

Quoted 8 lines
Quoted 5 lines
---
  drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
  2 files changed, 13 insertions(+), 18 deletions(-)

Thank you for testing Philipp :-)

Regards,
Phil