static void mwifiex_usb_disconnect(struct usb_interface *intf) { struct usb_card_rec *card = usb_get_intfdata(intf); struct mwifiex_adapter *adapter; wait_for_completion(&card->fw_done); adapter = card->adapter; if (!adapter || !adapter->priv_num) return; if (card->udev->state != USB_STATE_NOTATTACHED && !adapter->mfg_mode) { mwifiex_deauthenticate_all(adapter); mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), MWIFIEX_FUNC_SHUTDOWN); } mwifiex_usb_free(card); mwifiex_dbg(adapter, FATAL, "%s: removing card\n", __func__); mwifiex_remove_card(adapter); usb_put_dev(interface_to_usbdev(intf)); }
/* This function cleans up the USB driver. * * The following major steps are followed in .disconnect for cleanup: * - Resume the device if its suspended * - Disconnect the device if connected * - Shutdown the firmware * - Unregister the device from USB bus. */ static void mwifiex_usb_cleanup_module(void) { if (!down_interruptible(&add_remove_card_sem)) up(&add_remove_card_sem); if (usb_card && usb_card->adapter) { struct mwifiex_adapter *adapter = usb_card->adapter; /* In case driver is removed when asynchronous FW downloading is * in progress */ wait_for_completion(&adapter->fw_load); #ifdef CONFIG_PM if (adapter->is_suspended) mwifiex_usb_resume(usb_card->intf); #endif mwifiex_deauthenticate_all(adapter); mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), MWIFIEX_FUNC_SHUTDOWN); } usb_deregister(&mwifiex_usb_driver); }
static void mwifiex_usb_disconnect(struct usb_interface *intf) { struct usb_card_rec *card = usb_get_intfdata(intf); struct mwifiex_adapter *adapter; if (!card || !card->adapter) { pr_err("%s: card or card->adapter is NULL\n", __func__); return; } adapter = card->adapter; if (!adapter->priv_num) return; if (user_rmmod) { #ifdef CONFIG_PM if (adapter->is_suspended) mwifiex_usb_resume(intf); #endif mwifiex_deauthenticate_all(adapter); mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), MWIFIEX_FUNC_SHUTDOWN); } mwifiex_usb_free(card); mwifiex_dbg(adapter, FATAL, "%s: removing card\n", __func__); mwifiex_remove_card(adapter, &add_remove_card_sem); usb_set_intfdata(intf, NULL); usb_put_dev(interface_to_usbdev(intf)); kfree(card); return; }