mwifiex: stop AP at shutdown time
authorAmitkumar Karwar <akarwar@marvell.com>
Fri, 28 Feb 2014 03:35:17 +0000 (19:35 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Feb 2014 19:33:43 +0000 (14:33 -0500)
Deauth is sent to AP when the device is acting as station at
shutdown time. Similarly we should stop AP operation also.
mwifiex_deauthenticate() takes care closing the connection
based on provided interface type.

Add a new function to simplify the code.

Reported-by: Avery Pennarun <apenwarr@gmail.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/join.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/pcie.c
drivers/net/wireless/mwifiex/sdio.c
drivers/net/wireless/mwifiex/usb.c

index e9bd43526d80932ecaf556e667a883da5924e564..89dc62a467f4d2ba8b7cc2fcf6b7d1d63b058f68 100644 (file)
@@ -1443,7 +1443,20 @@ int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac)
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(mwifiex_deauthenticate);
+
+/* This function deauthenticates/disconnects from all BSS. */
+void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter)
+{
+       struct mwifiex_private *priv;
+       int i;
+
+       for (i = 0; i < adapter->priv_num; i++) {
+               priv = adapter->priv[i];
+               if (priv)
+                       mwifiex_deauthenticate(priv, NULL);
+       }
+}
+EXPORT_SYMBOL_GPL(mwifiex_deauthenticate_all);
 
 /*
  * This function converts band to radio type used in channel TLV.
index 6c04baa5bcf9176a1af0224b5eda5777f76510b3..e9d64fc7d7866d5257f0be0e5dc78ea70cdfb314 100644 (file)
@@ -927,6 +927,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
 u8 mwifiex_band_to_radio_type(u8 band);
 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
+void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
 int mwifiex_adhoc_start(struct mwifiex_private *priv,
                        struct cfg80211_ssid *adhoc_ssid);
 int mwifiex_adhoc_join(struct mwifiex_private *priv,
index 92c31b5c269c80c4cdad859c4b3d9063e336c084..d2af2127b41a2a2a57c694372a974084bef1340f 100644 (file)
@@ -211,7 +211,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
        struct pcie_service_card *card;
        struct mwifiex_adapter *adapter;
        struct mwifiex_private *priv;
-       int i;
 
        card = pci_get_drvdata(pdev);
        if (!card)
@@ -230,11 +229,7 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
                        mwifiex_pcie_resume(&pdev->dev);
 #endif
 
-               for (i = 0; i < adapter->priv_num; i++)
-                       if ((GET_BSS_ROLE(adapter->priv[i]) ==
-                            MWIFIEX_BSS_ROLE_STA) &&
-                           adapter->priv[i]->media_connected)
-                               mwifiex_deauthenticate(adapter->priv[i], NULL);
+               mwifiex_deauthenticate_all(adapter);
 
                priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
 
index d5661a6209be3af39f2ad93fe773f1b24e31c853..e0dcd3ed7a69d01d1a5342be587a8901e2b34b57 100644 (file)
@@ -166,7 +166,6 @@ mwifiex_sdio_remove(struct sdio_func *func)
        struct sdio_mmc_card *card;
        struct mwifiex_adapter *adapter;
        struct mwifiex_private *priv;
-       int i;
 
        pr_debug("info: SDIO func num=%d\n", func->num);
 
@@ -185,11 +184,7 @@ mwifiex_sdio_remove(struct sdio_func *func)
                if (adapter->is_suspended)
                        mwifiex_sdio_resume(adapter->dev);
 
-               for (i = 0; i < adapter->priv_num; i++)
-                       if ((GET_BSS_ROLE(adapter->priv[i]) ==
-                                               MWIFIEX_BSS_ROLE_STA) &&
-                           adapter->priv[i]->media_connected)
-                               mwifiex_deauthenticate(adapter->priv[i], NULL);
+               mwifiex_deauthenticate_all(adapter);
 
                priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
                mwifiex_disable_auto_ds(priv);
index 21d1316adaa0f457cd9eaf6d6e114745c5bffb56..93d5d73c4800e3c93949b66afb5288704ee59bd0 100644 (file)
@@ -1036,7 +1036,6 @@ static void mwifiex_usb_cleanup_module(void)
 
        if (usb_card && usb_card->adapter) {
                struct mwifiex_adapter *adapter = usb_card->adapter;
-               int i;
 
                /* In case driver is removed when asynchronous FW downloading is
                 * in progress
@@ -1047,11 +1046,8 @@ static void mwifiex_usb_cleanup_module(void)
                if (adapter->is_suspended)
                        mwifiex_usb_resume(usb_card->intf);
 #endif
-               for (i = 0; i < adapter->priv_num; i++)
-                       if ((GET_BSS_ROLE(adapter->priv[i]) ==
-                            MWIFIEX_BSS_ROLE_STA) &&
-                           adapter->priv[i]->media_connected)
-                               mwifiex_deauthenticate(adapter->priv[i], NULL);
+
+               mwifiex_deauthenticate_all(adapter);
 
                mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter,
                                                          MWIFIEX_BSS_ROLE_ANY),