static void sdio_dvobj_deinit(struct sdio_func *func) { struct dvobj_priv *dvobj = sdio_get_drvdata(func); _func_enter_; sdio_set_drvdata(func, NULL); if (dvobj) { sdio_deinit(dvobj); devobj_deinit(dvobj); } _func_exit_; return; }
static void rtw_dev_remove(struct sdio_func *func) { PADAPTER padapter; struct net_device *pnetdev; #ifdef CONFIG_IOCTL_CFG80211 struct wireless_dev *wdev; #endif _func_enter_; RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+rtw_dev_remove\n")); padapter = ((struct dvobj_priv*)sdio_get_drvdata(func))->padapter; #ifdef CONFIG_IOCTL_CFG80211 wdev = padapter->rtw_wdev; #endif #if defined(CONFIG_HAS_EARLYSUSPEND ) || defined(CONFIG_ANDROID_POWER) rtw_unregister_early_suspend(&padapter->pwrctrlpriv); #endif if (padapter->bSurpriseRemoved == _FALSE) { // test surprise remove int err; sdio_claim_host(func); sdio_readb(func, 0, &err); sdio_release_host(func); if (err == -ENOMEDIUM) { padapter->bSurpriseRemoved = _TRUE; DBG_871X(KERN_NOTICE "%s: device had been removed!\n", __func__); } } #ifdef CONFIG_HOSTAPD_MLME hostapd_mode_unload(padapter); #endif LeaveAllPowerSaveMode(padapter); pnetdev = (struct net_device*)padapter->pnetdev; if (pnetdev) { unregister_netdev(pnetdev); //will call netdev_close() RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("rtw_dev_remove: unregister netdev\n")); #ifdef CONFIG_PROC_DEBUG rtw_proc_remove_one(pnetdev); #endif } else { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_dev_remove: NO padapter->pnetdev!\n")); } rtw_cancel_all_timer(padapter); rtw_dev_unload(padapter); // interface deinit sdio_deinit(padapter); RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("rtw_dev_remove: deinit intf complete!\n")); rtw_free_drv_sw(padapter); #ifdef CONFIG_IOCTL_CFG80211 rtw_wdev_free(wdev); #endif RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("-rtw_dev_remove\n")); _func_exit_; }
/* * 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. */ static int rtw_drv_init( struct sdio_func *func, const struct sdio_device_id *id) { struct net_device *pnetdev; PADAPTER padapter; struct dvobj_priv *pdvobjpriv; PSDIO_DATA psdio; RT_TRACE(_module_hci_intfs_c_, _drv_info_, ("+rtw_drv_init: vendor=0x%04x device=0x%04x class=0x%02x\n", func->vendor, func->device, func->class)); //3 1. init network device data pnetdev = rtw_init_netdev(NULL); if (!pnetdev) goto error; SET_NETDEV_DEV(pnetdev, &func->dev); padapter = rtw_netdev_priv(pnetdev); pdvobjpriv = &padapter->dvobjpriv; pdvobjpriv->padapter = padapter; psdio = &pdvobjpriv->intf_data; psdio->func = func; #ifdef CONFIG_IOCTL_CFG80211 rtw_wdev_alloc(padapter, &func->dev); #endif //3 2. set interface private data sdio_set_drvdata(func, pdvobjpriv); //3 3. init driver special setting, interface, OS and hardware relative // set interface_type to sdio padapter->interface_type = RTW_SDIO; decide_chip_type_by_device_id(padapter, (u32)func->device); //4 3.1 set hardware operation functions padapter->HalData = rtw_zmalloc(sizeof(HAL_DATA_TYPE)); if (padapter->HalData == NULL) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: can't alloc memory for HAL DATA\n")); goto error; } padapter->hal_data_sz = sizeof(HAL_DATA_TYPE); set_hal_ops(padapter); //3 4. interface init if (sdio_init(padapter) != _SUCCESS) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: initialize device object priv Failed!\n")); goto error; } padapter->intf_start = &sd_intf_start; padapter->intf_stop = &sd_intf_stop; //3 5. register I/O operations if (rtw_init_io_priv(padapter) == _FAIL) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: Can't init io_priv\n")); goto deinit; } //3 6. intf_read_chip_version(padapter); //3 7. intf_chip_configure(padapter); //3 8. read efuse/eeprom data intf_read_chip_info(padapter); //3 9. init driver common data if (rtw_init_drv_sw(padapter) == _FAIL) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: Initialize driver software resource Failed!\n")); goto deinit; } //3 10. get WLan MAC address // alloc dev name after read efuse. rtw_init_netdev_name(pnetdev, ifname); rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); #ifdef CONFIG_PROC_DEBUG #ifdef RTK_DMP_PLATFORM rtw_proc_init_one(pnetdev); #endif #endif #ifdef CONFIG_HOSTAPD_MLME hostapd_mode_init(padapter); #endif #ifdef CONFIG_CONCURRENT_MODE //set global variable to primary adapter padapter->ph2c_fwcmd_mutex = &drvpriv.h2c_fwcmd_mutex; padapter->psetch_mutex = &drvpriv.setch_mutex; padapter->psetbw_mutex = &drvpriv.setbw_mutex; padapter->hw_init_mutex = &drvpriv.hw_init_mutex; #endif #ifdef CONFIG_PLATFORM_RTD2880B DBG_871X("wlan link up\n"); rtd2885_wlan_netlink_sendMsg("linkup", "8712"); #endif #ifdef CONFIG_GLOBAL_UI_PID if(ui_pid[1]!=0) { DBG_871X("ui_pid[1]:%d\n",ui_pid[1]); rtw_signal_process(ui_pid[1], SIGUSR2); } #endif DBG_871X("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" ,padapter->bDriverStopped ,padapter->bSurpriseRemoved ,padapter->bup ,padapter->hw_init_completed ); //3 8. Tell the network stack we exist if (register_netdev(pnetdev) != 0) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: register_netdev() failed\n")); goto deinit; } #ifdef CONFIG_CONCURRENT_MODE if(rtw_drv_if2_init(padapter)==_FAIL) { goto deinit; } #endif RT_TRACE(_module_hci_intfs_c_, _drv_info_, ("-rtw_drv_init: Success. bDriverStopped=%d bSurpriseRemoved=%d\n", padapter->bDriverStopped, padapter->bSurpriseRemoved)); return 0; deinit: sdio_deinit(padapter); error: if (padapter) { if (padapter->HalData && padapter->hal_data_sz>0) { rtw_mfree(padapter->HalData, padapter->hal_data_sz); padapter->HalData = NULL; } } if (pnetdev) rtw_free_netdev(pnetdev); RT_TRACE(_module_hci_intfs_c_, _drv_crit_, ("-rtw_drv_init: FAIL!\n")); return -1; }