mirror of
https://github.com/Mange/rtl8192eu-linux-driver
synced 2024-12-23 20:41:43 +00:00
Reorganize error handling in rtw_drv_init()
Looking at the error function as a whole, the error handling is odd compared to the rest of the kernel, which prefers to set error codes on goto paths, rather than a global "status" variable which determines the error code at the end of the function and function calls in the case of error. Rearrange the error handling of this function to bring it more inline with how the kernel does it in most cases, which helps readability. Link: https://lore.kernel.org/r/20210812204027.338872-4-nathan@kernel.org Link: https://lore.kernel.org/r/20210813201418.4018631-1-nathan@kernel.org
This commit is contained in:
parent
8d93cdeefa
commit
c597fa83da
@ -1471,7 +1471,6 @@ static void rtw_usb_primary_adapter_deinit(_adapter *padapter)
|
||||
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
|
||||
{
|
||||
_adapter *padapter = NULL;
|
||||
int status = _FAIL;
|
||||
struct dvobj_priv *dvobj;
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
int i;
|
||||
@ -1484,8 +1483,8 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
|
||||
|
||||
/* Initialize dvobj_priv */
|
||||
dvobj = usb_dvobj_init(pusb_intf, pdid);
|
||||
if (dvobj == NULL) {
|
||||
goto exit;
|
||||
if (!dvobj) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
padapter = rtw_usb_primary_adapter_init(dvobj, pusb_intf);
|
||||
@ -1534,30 +1533,21 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
|
||||
#endif
|
||||
|
||||
|
||||
status = _SUCCESS;
|
||||
return 0;
|
||||
|
||||
#if 0 /* not used now */
|
||||
os_ndevs_deinit:
|
||||
if (status != _SUCCESS)
|
||||
rtw_os_ndevs_deinit(dvobj);
|
||||
#endif
|
||||
free_if_vir:
|
||||
if (status != _SUCCESS) {
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
rtw_drv_stop_vir_ifaces(dvobj);
|
||||
rtw_drv_free_vir_ifaces(dvobj);
|
||||
#endif
|
||||
}
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
rtw_drv_stop_vir_ifaces(dvobj);
|
||||
rtw_drv_free_vir_ifaces(dvobj);
|
||||
#endif
|
||||
|
||||
free_if_prim:
|
||||
if (status != _SUCCESS && padapter)
|
||||
rtw_usb_primary_adapter_deinit(padapter);
|
||||
rtw_usb_primary_adapter_deinit(padapter);
|
||||
|
||||
free_dvobj:
|
||||
if (status != _SUCCESS)
|
||||
usb_dvobj_deinit(pusb_intf);
|
||||
exit:
|
||||
return status == _SUCCESS ? 0 : -ENODEV;
|
||||
usb_dvobj_deinit(pusb_intf);
|
||||
err:
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user