[PATCH 10/10] staging: rtl8188eu: return an error code, not a boolean

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Several functions in this driver return a boolean: _SUCCESS = 1 on success,
_FAIL = 0 on error, defined in
drivers/staging/rtl8188eu/include/osdep_service.h.

The common practice in the Linux kernel is to return 0 on success, a negative
error code otherwise. This has the advantage that the return value also
describes the kind of error that happened, while a boolean squashes all errors
down a unique value.

Change rtw_start_drv_threads() to return a proper 0-or-error value.

Signed-off-by: Luca Ceresoli <luca@xxxxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxx>
Cc: Larry Finger <Larry.Finger@xxxxxxxxxxxx>

---

I think _SUCCESS and _FAIL should be totally eradicated and replaced with
proper error codes and my intent is to do it all over the codebase.
However, since that would be a massive change, I'm sending this small
patch to get some feedback. Should the idea be accepted, I'd go on.
---
 drivers/staging/rtl8188eu/os_dep/os_intfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 4763c85..6a8a9f6 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -752,21 +752,21 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
 	return pnetdev;
 }
 
-static u32 rtw_start_drv_threads(struct adapter *padapter)
+static int rtw_start_drv_threads(struct adapter *padapter)
 {
-	u32 _status = _SUCCESS;
+	int err = 0;
 
 	RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n"));
 
 	padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter,
 					  "RTW_CMD_THREAD");
 	if (IS_ERR(padapter->cmdThread))
-		_status = _FAIL;
+		err = PTR_ERR(padapter->cmdThread);
 	else
 		/* wait for cmd_thread to run */
 		_rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
 
-	return _status;
+	return err;
 }
 
 void rtw_stop_drv_threads(struct adapter *padapter)
@@ -1003,7 +1003,7 @@ static int _netdev_open(struct net_device *pnetdev)
 		pr_info("MAC Address = %pM\n", pnetdev->dev_addr);
 
 		status = rtw_start_drv_threads(padapter);
-		if (status == _FAIL) {
+		if (status != 0) {
 			pr_info("Initialize driver software resource Failed!\n");
 			goto netdev_open_error;
 		}
-- 
1.9.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux