public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics
@ 2022-08-02 23:44 Phillip Potter
  2022-08-03 12:11 ` Dan Carpenter
  2022-08-04 20:26 ` Philipp Hortmann
  0 siblings, 2 replies; 5+ messages in thread
From: Phillip Potter @ 2022-08-02 23:44 UTC (permalink / raw)
  To: gregkh
  Cc: Larry.Finger, paskripkin, straube.linux, martin, abdun.nihaal,
	linux-staging, linux-kernel

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.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
 drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c
index bd654d4ff8b4..dc159e58f428 100644
--- a/drivers/staging/r8188eu/core/rtw_p2p.c
+++ b/drivers/staging/r8188eu/core/rtw_p2p.c
@@ -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;
 }
diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 7f91dac2e41b..e9802d42aa1b 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -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,
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics
  2022-08-02 23:44 [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics Phillip Potter
@ 2022-08-03 12:11 ` Dan Carpenter
  2022-08-04 22:35   ` Phillip Potter
  2022-08-04 20:26 ` Philipp Hortmann
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2022-08-03 12:11 UTC (permalink / raw)
  To: Phillip Potter
  Cc: gregkh, Larry.Finger, paskripkin, straube.linux, martin,
	abdun.nihaal, linux-staging, linux-kernel

On Wed, Aug 03, 2022 at 12:44:08AM +0100, Phillip Potter wrote:
> 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.
> 
> Signed-off-by: Phillip Potter <phil@philpotter.co.uk>

Looks good.  Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics
  2022-08-02 23:44 [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics Phillip Potter
  2022-08-03 12:11 ` Dan Carpenter
@ 2022-08-04 20:26 ` Philipp Hortmann
  2022-08-04 22:37   ` Phillip Potter
  1 sibling, 1 reply; 5+ messages in thread
From: Philipp Hortmann @ 2022-08-04 20:26 UTC (permalink / raw)
  To: Phillip Potter, gregkh
  Cc: Larry.Finger, paskripkin, straube.linux, martin, abdun.nihaal,
	linux-staging, linux-kernel

On 8/3/22 01:44, Phillip Potter wrote:
> 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.
> 
> Signed-off-by: Phillip Potter<phil@philpotter.co.uk>
> ---
>   drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
>   drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
>   2 files changed, 13 insertions(+), 18 deletions(-)


Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics
  2022-08-03 12:11 ` Dan Carpenter
@ 2022-08-04 22:35   ` Phillip Potter
  0 siblings, 0 replies; 5+ messages in thread
From: Phillip Potter @ 2022-08-04 22:35 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh, Larry.Finger, paskripkin, straube.linux, martin,
	abdun.nihaal, linux-staging, linux-kernel

On Wed, Aug 03, 2022 at 03:11:08PM +0300, Dan Carpenter wrote:
> On Wed, Aug 03, 2022 at 12:44:08AM +0100, Phillip Potter wrote:
> > 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.
> > 
> > Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
> 
> Looks good.  Thanks!
> 
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> regards,
> dan carpenter
> 

Thanks for the review Dan, much appreciated.

Regards,
Phil

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics
  2022-08-04 20:26 ` Philipp Hortmann
@ 2022-08-04 22:37   ` Phillip Potter
  0 siblings, 0 replies; 5+ messages in thread
From: Phillip Potter @ 2022-08-04 22:37 UTC (permalink / raw)
  To: Philipp Hortmann
  Cc: gregkh, Larry.Finger, paskripkin, straube.linux, martin,
	abdun.nihaal, linux-staging, linux-kernel

On Thu, Aug 04, 2022 at 10:26:39PM +0200, Philipp Hortmann wrote:
> On 8/3/22 01:44, Phillip Potter wrote:
> > 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.
> > 
> > Signed-off-by: Phillip Potter<phil@philpotter.co.uk>
> > ---
> >   drivers/staging/r8188eu/core/rtw_p2p.c       | 19 ++++++++-----------
> >   drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++-------
> >   2 files changed, 13 insertions(+), 18 deletions(-)
> 
> 
> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

Thank you for testing Philipp :-)

Regards,
Phil

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-04 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 23:44 [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics Phillip Potter
2022-08-03 12:11 ` Dan Carpenter
2022-08-04 22:35   ` Phillip Potter
2022-08-04 20:26 ` Philipp Hortmann
2022-08-04 22:37   ` Phillip Potter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox