All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads()
@ 2022-11-06 13:34 Michael Straube
  2022-11-06 14:35 ` Deepak R Varma
  2022-11-07  6:22 ` Philipp Hortmann
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Straube @ 2022-11-06 13:34 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Convert the error handling in the function rtw_start_drv_threads() to
the common logic used in the kernel. Another step to get rid of _FAIL
and _SUCCESS which uses inverted logic.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/include/osdep_intf.h |  2 +-
 drivers/staging/r8188eu/os_dep/os_intfs.c    | 17 +++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h
index 0f7d74a3ff6d..6d66cb57225e 100644
--- a/drivers/staging/r8188eu/include/osdep_intf.h
+++ b/drivers/staging/r8188eu/include/osdep_intf.h
@@ -46,7 +46,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter);
 void rtw_free_drv_sw(struct adapter *padapter);
 void rtw_reset_drv_sw(struct adapter *padapter);
 
-u32 rtw_start_drv_threads(struct adapter *padapter);
+int rtw_start_drv_threads(struct adapter *padapter);
 void rtw_stop_drv_threads (struct adapter *padapter);
 void rtw_cancel_all_timer(struct adapter *padapter);
 
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index 970f380bac96..66556e07ed93 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -363,18 +363,16 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
 	return pnetdev;
 }
 
-u32 rtw_start_drv_threads(struct adapter *padapter)
+int rtw_start_drv_threads(struct adapter *padapter)
 {
-	u32 _status = _SUCCESS;
-
 	padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
 	if (IS_ERR(padapter->cmdThread))
-		_status = _FAIL;
-	else
-		/* wait for rtw_cmd_thread() to start running */
-		wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
+		return PTR_ERR(padapter->cmdThread);
 
-	return _status;
+	/* wait for rtw_cmd_thread() to start running */
+	wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
+
+	return 0;
 }
 
 void rtw_stop_drv_threads(struct adapter *padapter)
@@ -627,8 +625,7 @@ static int _netdev_open(struct net_device *pnetdev)
 
 		netdev_dbg(pnetdev, "MAC Address = %pM\n", pnetdev->dev_addr);
 
-		status = rtw_start_drv_threads(padapter);
-		if (status == _FAIL) {
+		if (rtw_start_drv_threads(padapter)) {
 			pr_info("Initialize driver software resource Failed!\n");
 			goto netdev_open_error;
 		}
-- 
2.38.0


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

* Re: [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads()
  2022-11-06 13:34 [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads() Michael Straube
@ 2022-11-06 14:35 ` Deepak R Varma
  2022-11-06 15:34   ` Michael Straube
  2022-11-07  6:22 ` Philipp Hortmann
  1 sibling, 1 reply; 5+ messages in thread
From: Deepak R Varma @ 2022-11-06 14:35 UTC (permalink / raw)
  To: Michael Straube; +Cc: gregkh, Larry.Finger, phil, linux-staging, linux-kernel

On Sun, Nov 06, 2022 at 02:34:43PM +0100, Michael Straube wrote:
> Convert the error handling in the function rtw_start_drv_threads() to
> the common logic used in the kernel. Another step to get rid of _FAIL
> and _SUCCESS which uses inverted logic.

Hello Michael,
Can you please tell how did you find this opportunity for improvement? Are you
using some tool or is it a manual code review/analysis?

Thank you,
./drv

>
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>  drivers/staging/r8188eu/include/osdep_intf.h |  2 +-
>  drivers/staging/r8188eu/os_dep/os_intfs.c    | 17 +++++++----------
>  2 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h
> index 0f7d74a3ff6d..6d66cb57225e 100644
> --- a/drivers/staging/r8188eu/include/osdep_intf.h
> +++ b/drivers/staging/r8188eu/include/osdep_intf.h
> @@ -46,7 +46,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter);
>  void rtw_free_drv_sw(struct adapter *padapter);
>  void rtw_reset_drv_sw(struct adapter *padapter);
>
> -u32 rtw_start_drv_threads(struct adapter *padapter);
> +int rtw_start_drv_threads(struct adapter *padapter);
>  void rtw_stop_drv_threads (struct adapter *padapter);
>  void rtw_cancel_all_timer(struct adapter *padapter);
>
> diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
> index 970f380bac96..66556e07ed93 100644
> --- a/drivers/staging/r8188eu/os_dep/os_intfs.c
> +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
> @@ -363,18 +363,16 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
>  	return pnetdev;
>  }
>
> -u32 rtw_start_drv_threads(struct adapter *padapter)
> +int rtw_start_drv_threads(struct adapter *padapter)
>  {
> -	u32 _status = _SUCCESS;
> -
>  	padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
>  	if (IS_ERR(padapter->cmdThread))
> -		_status = _FAIL;
> -	else
> -		/* wait for rtw_cmd_thread() to start running */
> -		wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
> +		return PTR_ERR(padapter->cmdThread);
>
> -	return _status;
> +	/* wait for rtw_cmd_thread() to start running */
> +	wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
> +
> +	return 0;
>  }
>
>  void rtw_stop_drv_threads(struct adapter *padapter)
> @@ -627,8 +625,7 @@ static int _netdev_open(struct net_device *pnetdev)
>
>  		netdev_dbg(pnetdev, "MAC Address = %pM\n", pnetdev->dev_addr);
>
> -		status = rtw_start_drv_threads(padapter);
> -		if (status == _FAIL) {
> +		if (rtw_start_drv_threads(padapter)) {
>  			pr_info("Initialize driver software resource Failed!\n");
>  			goto netdev_open_error;
>  		}
> --
> 2.38.0
>
>



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

* Re: [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads()
  2022-11-06 14:35 ` Deepak R Varma
@ 2022-11-06 15:34   ` Michael Straube
  2022-11-06 15:52     ` Deepak R Varma
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Straube @ 2022-11-06 15:34 UTC (permalink / raw)
  To: Deepak R Varma; +Cc: gregkh, Larry.Finger, phil, linux-staging, linux-kernel

On 11/6/22 15:35, Deepak R Varma wrote:
> On Sun, Nov 06, 2022 at 02:34:43PM +0100, Michael Straube wrote:
>> Convert the error handling in the function rtw_start_drv_threads() to
>> the common logic used in the kernel. Another step to get rid of _FAIL
>> and _SUCCESS which uses inverted logic.
> 
> Hello Michael,
> Can you please tell how did you find this opportunity for improvement? Are you
> using some tool or is it a manual code review/analysis?
> 

Hi Deepak,

I just used git grep to search for _FAIL or _SUCCESS and then looked at
the code manually.

Regards,
Michael

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

* Re: [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads()
  2022-11-06 15:34   ` Michael Straube
@ 2022-11-06 15:52     ` Deepak R Varma
  0 siblings, 0 replies; 5+ messages in thread
From: Deepak R Varma @ 2022-11-06 15:52 UTC (permalink / raw)
  To: Michael Straube; +Cc: gregkh, Larry.Finger, phil, linux-staging, linux-kernel

On Sun, Nov 06, 2022 at 04:34:57PM +0100, Michael Straube wrote:
> On 11/6/22 15:35, Deepak R Varma wrote:
> > On Sun, Nov 06, 2022 at 02:34:43PM +0100, Michael Straube wrote:
> > > Convert the error handling in the function rtw_start_drv_threads() to
> > > the common logic used in the kernel. Another step to get rid of _FAIL
> > > and _SUCCESS which uses inverted logic.
> >
> > Hello Michael,
> > Can you please tell how did you find this opportunity for improvement? Are you
> > using some tool or is it a manual code review/analysis?
> >
>
> Hi Deepak,
>
> I just used git grep to search for _FAIL or _SUCCESS and then looked at
> the code manually.
>
> Regards,
> Michael
>

Okay. That is very helpful. Thank you Michael.

./drv



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

* Re: [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads()
  2022-11-06 13:34 [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads() Michael Straube
  2022-11-06 14:35 ` Deepak R Varma
@ 2022-11-07  6:22 ` Philipp Hortmann
  1 sibling, 0 replies; 5+ messages in thread
From: Philipp Hortmann @ 2022-11-07  6:22 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On 11/6/22 14:34, Michael Straube wrote:
> Convert the error handling in the function rtw_start_drv_threads() to
> the common logic used in the kernel. Another step to get rid of _FAIL
> and _SUCCESS which uses inverted logic.
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>   drivers/staging/r8188eu/include/osdep_intf.h |  2 +-
>   drivers/staging/r8188eu/os_dep/os_intfs.c    | 17 +++++++----------
>   2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h
> index 0f7d74a3ff6d..6d66cb57225e 100644
> --- a/drivers/staging/r8188eu/include/osdep_intf.h
> +++ b/drivers/staging/r8188eu/include/osdep_intf.h
> @@ -46,7 +46,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter);
>   void rtw_free_drv_sw(struct adapter *padapter);
>   void rtw_reset_drv_sw(struct adapter *padapter);
>   
> -u32 rtw_start_drv_threads(struct adapter *padapter);
> +int rtw_start_drv_threads(struct adapter *padapter);
>   void rtw_stop_drv_threads (struct adapter *padapter);
>   void rtw_cancel_all_timer(struct adapter *padapter);
>   
> diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
> index 970f380bac96..66556e07ed93 100644
> --- a/drivers/staging/r8188eu/os_dep/os_intfs.c
> +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
> @@ -363,18 +363,16 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
>   	return pnetdev;
>   }
>   
> -u32 rtw_start_drv_threads(struct adapter *padapter)
> +int rtw_start_drv_threads(struct adapter *padapter)
>   {
> -	u32 _status = _SUCCESS;
> -
>   	padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
>   	if (IS_ERR(padapter->cmdThread))
> -		_status = _FAIL;
> -	else
> -		/* wait for rtw_cmd_thread() to start running */
> -		wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
> +		return PTR_ERR(padapter->cmdThread);
>   
> -	return _status;
> +	/* wait for rtw_cmd_thread() to start running */
> +	wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
> +
> +	return 0;
>   }
>   
>   void rtw_stop_drv_threads(struct adapter *padapter)
> @@ -627,8 +625,7 @@ static int _netdev_open(struct net_device *pnetdev)
>   
>   		netdev_dbg(pnetdev, "MAC Address = %pM\n", pnetdev->dev_addr);
>   
> -		status = rtw_start_drv_threads(padapter);
> -		if (status == _FAIL) {
> +		if (rtw_start_drv_threads(padapter)) {
>   			pr_info("Initialize driver software resource Failed!\n");
>   			goto netdev_open_error;
>   		}
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

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

end of thread, other threads:[~2022-11-07  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-06 13:34 [PATCH] staging: r8188eu: clean up error handling in rtw_start_drv_threads() Michael Straube
2022-11-06 14:35 ` Deepak R Varma
2022-11-06 15:34   ` Michael Straube
2022-11-06 15:52     ` Deepak R Varma
2022-11-07  6:22 ` Philipp Hortmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.