mirror of
https://github.com/Mange/rtl8192eu-linux-driver
synced 2024-11-22 21:45:22 +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)
|
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
|
||||||
{
|
{
|
||||||
_adapter *padapter = NULL;
|
_adapter *padapter = NULL;
|
||||||
int status = _FAIL;
|
|
||||||
struct dvobj_priv *dvobj;
|
struct dvobj_priv *dvobj;
|
||||||
#ifdef CONFIG_CONCURRENT_MODE
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
int i;
|
int i;
|
||||||
@ -1484,8 +1483,8 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
|
|||||||
|
|
||||||
/* Initialize dvobj_priv */
|
/* Initialize dvobj_priv */
|
||||||
dvobj = usb_dvobj_init(pusb_intf, pdid);
|
dvobj = usb_dvobj_init(pusb_intf, pdid);
|
||||||
if (dvobj == NULL) {
|
if (!dvobj) {
|
||||||
goto exit;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
padapter = rtw_usb_primary_adapter_init(dvobj, pusb_intf);
|
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
|
#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:
|
free_if_vir:
|
||||||
if (status != _SUCCESS) {
|
|
||||||
#ifdef CONFIG_CONCURRENT_MODE
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
rtw_drv_stop_vir_ifaces(dvobj);
|
rtw_drv_stop_vir_ifaces(dvobj);
|
||||||
rtw_drv_free_vir_ifaces(dvobj);
|
rtw_drv_free_vir_ifaces(dvobj);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
free_if_prim:
|
free_if_prim:
|
||||||
if (status != _SUCCESS && padapter)
|
|
||||||
rtw_usb_primary_adapter_deinit(padapter);
|
rtw_usb_primary_adapter_deinit(padapter);
|
||||||
|
|
||||||
free_dvobj:
|
free_dvobj:
|
||||||
if (status != _SUCCESS)
|
|
||||||
usb_dvobj_deinit(pusb_intf);
|
usb_dvobj_deinit(pusb_intf);
|
||||||
exit:
|
err:
|
||||||
return status == _SUCCESS ? 0 : -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user