os_dep/linux/pci_intf.c
static int rtw_drv_init(struct pci_dev *pdev, const struct pci_device_id *pdid)
{
	int i, err = -ENODEV;

	int status = _FAIL;
	_adapter *padapter = NULL;
	struct dvobj_priv *dvobj;
	struct net_device *pnetdev;

	/* RTW_INFO("+rtw_drv_init\n"); */

	/* step 0. */
	disable_ht_for_spec_devid(pdid);

	/* Initialize dvobj_priv */
	dvobj = pci_dvobj_init(pdev, pdid);
	if (dvobj == NULL)
		goto exit;

	/* Initialize primary adapter */
	padapter = rtw_pci_primary_adapter_init(dvobj, pdev);
	if (padapter == NULL) {
		RTW_INFO("rtw_pci_primary_adapter_init Failed!\n");
		goto free_dvobj;
	}

	/* Initialize virtual interface */
#ifdef CONFIG_CONCURRENT_MODE
	if (padapter->registrypriv.virtual_iface_num > (CONFIG_IFACE_NUMBER - 1))
		padapter->registrypriv.virtual_iface_num = (CONFIG_IFACE_NUMBER - 1);

	for (i = 0; i < padapter->registrypriv.virtual_iface_num; i++) {
		if (rtw_drv_add_vir_if(padapter, pci_set_intf_ops) == NULL) {
			RTW_INFO("rtw_drv_add_iface failed! (%d)\n", i);
			goto free_if_vir;
		}
	}
#endif

#ifdef CONFIG_GLOBAL_UI_PID
	if (ui_pid[1] != 0) {
		RTW_INFO("ui_pid[1]:%d\n", ui_pid[1]);
		rtw_signal_process(ui_pid[1], SIGUSR2);
	}
#endif

	/* dev_alloc_name && register_netdev */
	if (rtw_os_ndevs_init(dvobj) != _SUCCESS)
		goto free_if_vir;

#ifdef CONFIG_HOSTAPD_MLME
	hostapd_mode_init(padapter);
#endif

#ifdef CONFIG_PLATFORM_RTD2880B
	RTW_INFO("wlan link up\n");
	rtd2885_wlan_netlink_sendMsg("linkup", "8712");
#endif

	/* alloc irq */
	if (pci_alloc_irq(dvobj) != _SUCCESS)
		goto os_ndevs_deinit;

	/* RTW_INFO("-871x_drv - drv_init, success!\n"); */

	status = _SUCCESS;

os_ndevs_deinit:
	if (status != _SUCCESS)
		rtw_os_ndevs_deinit(dvobj);
free_if_vir:
	if (status != _SUCCESS) {
#ifdef CONFIG_CONCURRENT_MODE
		rtw_drv_stop_vir_ifaces(dvobj);
		rtw_drv_free_vir_ifaces(dvobj);
#endif
	}

	if (status != _SUCCESS && padapter)
		rtw_pci_primary_adapter_deinit(padapter);

free_dvobj:
	if (status != _SUCCESS)
		pci_dvobj_deinit(pdev);
exit:
	return status == _SUCCESS ? 0 : -ENODEV;
}
/*
 * drv_init() - a device potentially for us
 *
 * notes: drv_init() is called when the bus driver has located a card for us to support.
 *        We accept the new device by returning 0.
*/
a device potentially for us
notes: drv_init() is called when the bus driver has located a card for us to support.
We accept the new device by returning 0.
a device potentially for us notes : drv_init () is called when the bus driver has located a card for us to support . We accept the new device by returning 0 .
static int rtw_drv_init(struct pci_dev *pdev, const struct pci_device_id *pdid)
{
	int i, err = -ENODEV;
	int status = _FAIL;
	_adapter *padapter = NULL;
	struct dvobj_priv *dvobj;
	struct net_device *pnetdev;
	disable_ht_for_spec_devid(pdid);
	dvobj = pci_dvobj_init(pdev, pdid);
	if (dvobj == NULL)
		goto exit;
	padapter = rtw_pci_primary_adapter_init(dvobj, pdev);
	if (padapter == NULL) {
		RTW_INFO("rtw_pci_primary_adapter_init Failed!\n");
		goto free_dvobj;
	}
#ifdef CONFIG_CONCURRENT_MODE
	if (padapter->registrypriv.virtual_iface_num > (CONFIG_IFACE_NUMBER - 1))
		padapter->registrypriv.virtual_iface_num = (CONFIG_IFACE_NUMBER - 1);
	for (i = 0; i < padapter->registrypriv.virtual_iface_num; i++) {
		if (rtw_drv_add_vir_if(padapter, pci_set_intf_ops) == NULL) {
			RTW_INFO("rtw_drv_add_iface failed! (%d)\n", i);
			goto free_if_vir;
		}
	}
#endif
#ifdef CONFIG_GLOBAL_UI_PID
	if (ui_pid[1] != 0) {
		RTW_INFO("ui_pid[1]:%d\n", ui_pid[1]);
		rtw_signal_process(ui_pid[1], SIGUSR2);
	}
#endif
	if (rtw_os_ndevs_init(dvobj) != _SUCCESS)
		goto free_if_vir;
#ifdef CONFIG_HOSTAPD_MLME
	hostapd_mode_init(padapter);
#endif
#ifdef CONFIG_PLATFORM_RTD2880B
	RTW_INFO("wlan link up\n");
	rtd2885_wlan_netlink_sendMsg("linkup", "8712");
#endif
	if (pci_alloc_irq(dvobj) != _SUCCESS)
		goto os_ndevs_deinit;
	status = _SUCCESS;
os_ndevs_deinit:
	if (status != _SUCCESS)
		rtw_os_ndevs_deinit(dvobj);
free_if_vir:
	if (status != _SUCCESS) {
#ifdef CONFIG_CONCURRENT_MODE
		rtw_drv_stop_vir_ifaces(dvobj);
		rtw_drv_free_vir_ifaces(dvobj);
#endif
	}
	if (status != _SUCCESS && padapter)
		rtw_pci_primary_adapter_deinit(padapter);
free_dvobj:
	if (status != _SUCCESS)
		pci_dvobj_deinit(pdev);
exit:
	return status == _SUCCESS ? 0 : -ENODEV;
}
static int rtw_drv_init ( struct pci_dev * pdev , const struct pci_device_id * pdid ) { int i , err = - ENODEV ; int status = _FAIL ; _adapter * padapter = NULL ; struct dvobj_priv * dvobj ; struct net_device * pnetdev ; disable_ht_for_spec_devid ( pdid ) ; dvobj = pci_dvobj_init ( pdev , pdid ) ; if ( dvobj == NULL ) goto exit ; padapter = rtw_pci_primary_adapter_init ( dvobj , pdev ) ; if ( padapter == NULL ) { RTW_INFO ( " \n " ) ; goto free_dvobj ; } #ifdef CONFIG_CONCURRENT_MODE if ( padapter -> registrypriv . virtual_iface_num > ( CONFIG_IFACE_NUMBER - 1 ) ) padapter -> registrypriv . virtual_iface_num = ( CONFIG_IFACE_NUMBER - 1 ) ; for ( i = 0 ; i < padapter -> registrypriv . virtual_iface_num ; i ++ ) { if ( rtw_drv_add_vir_if ( padapter , pci_set_intf_ops ) == NULL ) { RTW_INFO ( " \n " , i ) ; goto free_if_vir ; } } #endif #ifdef CONFIG_GLOBAL_UI_PID if ( ui_pid [ 1 ] != 0 ) { RTW_INFO ( " \n " , ui_pid [ 1 ] ) ; rtw_signal_process ( ui_pid [ 1 ] , SIGUSR2 ) ; } #endif if ( rtw_os_ndevs_init ( dvobj ) != _SUCCESS ) goto free_if_vir ; #ifdef CONFIG_HOSTAPD_MLME hostapd_mode_init ( padapter ) ; #endif #ifdef CONFIG_PLATFORM_RTD2880B RTW_INFO ( " \n " ) ; rtd2885_wlan_netlink_sendMsg ( " " , " " ) ; #endif if ( pci_alloc_irq ( dvobj ) != _SUCCESS ) goto os_ndevs_deinit ; status = _SUCCESS ; os_ndevs_deinit : if ( status != _SUCCESS ) rtw_os_ndevs_deinit ( dvobj ) ; free_if_vir : if ( status != _SUCCESS ) { #ifdef CONFIG_CONCURRENT_MODE rtw_drv_stop_vir_ifaces ( dvobj ) ; rtw_drv_free_vir_ifaces ( dvobj ) ; #endif } if ( status != _SUCCESS && padapter ) rtw_pci_primary_adapter_deinit ( padapter ) ; free_dvobj : if ( status != _SUCCESS ) pci_dvobj_deinit ( pdev ) ; exit : return status == _SUCCESS ? 0 : - ENODEV ; }
drv_init() - a device potentially for us
 notes: drv_init() is called when the bus driver has located a card for us to support.
drv_init () - a device potentially for us notes : drv_init () is called when the bus driver has located a card for us to support .
/* RTW_INFO("+rtw_drv_init\n"); */ /* step 0. */ /* Initialize dvobj_priv */ /* Initialize primary adapter */ /* Initialize virtual interface */ /* dev_alloc_name && register_netdev */ /* alloc irq */ /* RTW_INFO("-871x_drv - drv_init, success!\n"); */