提交 b6658b66 编写于 作者: B Brian Norris 提交者: Kalle Valo

mwifiex: reunite copy-and-pasted remove/reset code

When PCIe FLR code was added, it explicitly copy-and-pasted much of
mwifiex_remove_card() into mwifiex_shutdown_sw(). This is unnecessary,
as almost all of the code should be reused.

Let's reunite what we can for now.

The only functional changes for now:

 * call netif_device_detach() in the remove() code path -- this wasn't
   done before, but it really should be a no-op, when the device is
   getting totally unregistered soon anyway

 * call the ->down_dev() driver callback only after we've finished all
   SW teardown -- this should have no significant effect, since the only
   user (pcie.c) does very minimal work there, and it doesn't matter
   that we reorder this
Signed-off-by: NBrian Norris <briannorris@chromium.org>
Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
上级 e6249e15
...@@ -1352,26 +1352,12 @@ static void mwifiex_main_work_queue(struct work_struct *work) ...@@ -1352,26 +1352,12 @@ static void mwifiex_main_work_queue(struct work_struct *work)
mwifiex_main_process(adapter); mwifiex_main_process(adapter);
} }
/* /* Common teardown code used for both device removal and reset */
* This function gets called during PCIe function level reset. Required static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter)
* code is extracted from mwifiex_remove_card()
*/
int
mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
{ {
struct mwifiex_private *priv; struct mwifiex_private *priv;
int i; int i;
if (!adapter)
goto exit_return;
wait_for_completion(adapter->fw_done);
/* Caller should ensure we aren't suspending while this happens */
reinit_completion(adapter->fw_done);
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
mwifiex_deauthenticate(priv, NULL);
/* We can no longer handle interrupts once we start doing the teardown /* We can no longer handle interrupts once we start doing the teardown
* below. * below.
*/ */
...@@ -1393,12 +1379,9 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) ...@@ -1393,12 +1379,9 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
} }
mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n"); mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n");
mwifiex_shutdown_drv(adapter); mwifiex_shutdown_drv(adapter);
if (adapter->if_ops.down_dev)
adapter->if_ops.down_dev(adapter);
mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n"); mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n");
if (atomic_read(&adapter->rx_pending) || if (atomic_read(&adapter->rx_pending) ||
atomic_read(&adapter->tx_pending) || atomic_read(&adapter->tx_pending) ||
atomic_read(&adapter->cmd_pending)) { atomic_read(&adapter->cmd_pending)) {
...@@ -1421,9 +1404,30 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) ...@@ -1421,9 +1404,30 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
rtnl_unlock(); rtnl_unlock();
} }
vfree(adapter->chan_stats); vfree(adapter->chan_stats);
}
/*
* This function gets called during PCIe function level reset.
*/
int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
{
struct mwifiex_private *priv;
if (!adapter)
return 0;
wait_for_completion(adapter->fw_done);
/* Caller should ensure we aren't suspending while this happens */
reinit_completion(adapter->fw_done);
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
mwifiex_deauthenticate(priv, NULL);
mwifiex_uninit_sw(adapter);
if (adapter->if_ops.down_dev)
adapter->if_ops.down_dev(adapter);
mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
exit_return:
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw); EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw);
...@@ -1676,61 +1680,10 @@ EXPORT_SYMBOL_GPL(mwifiex_add_card); ...@@ -1676,61 +1680,10 @@ EXPORT_SYMBOL_GPL(mwifiex_add_card);
*/ */
int mwifiex_remove_card(struct mwifiex_adapter *adapter) int mwifiex_remove_card(struct mwifiex_adapter *adapter)
{ {
struct mwifiex_private *priv = NULL;
int i;
if (!adapter) if (!adapter)
goto exit_remove; return 0;
/* We can no longer handle interrupts once we start doing the teardown
* below. */
if (adapter->if_ops.disable_int)
adapter->if_ops.disable_int(adapter);
adapter->surprise_removed = true;
mwifiex_terminate_workqueue(adapter);
/* Stop data */
for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i];
if (priv && priv->netdev) {
mwifiex_stop_net_dev_queue(priv->netdev, adapter);
if (netif_carrier_ok(priv->netdev))
netif_carrier_off(priv->netdev);
}
}
mwifiex_dbg(adapter, CMD,
"cmd: calling mwifiex_shutdown_drv...\n");
mwifiex_shutdown_drv(adapter);
mwifiex_dbg(adapter, CMD,
"cmd: mwifiex_shutdown_drv done\n");
if (atomic_read(&adapter->rx_pending) ||
atomic_read(&adapter->tx_pending) ||
atomic_read(&adapter->cmd_pending)) {
mwifiex_dbg(adapter, ERROR,
"rx_pending=%d, tx_pending=%d,\t"
"cmd_pending=%d\n",
atomic_read(&adapter->rx_pending),
atomic_read(&adapter->tx_pending),
atomic_read(&adapter->cmd_pending));
}
for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i];
if (!priv)
continue;
rtnl_lock(); mwifiex_uninit_sw(adapter);
if (priv->netdev &&
priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED)
mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
rtnl_unlock();
}
vfree(adapter->chan_stats);
wiphy_unregister(adapter->wiphy); wiphy_unregister(adapter->wiphy);
wiphy_free(adapter->wiphy); wiphy_free(adapter->wiphy);
...@@ -1748,7 +1701,6 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter) ...@@ -1748,7 +1701,6 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter)
"info: free adapter\n"); "info: free adapter\n");
mwifiex_free_adapter(adapter); mwifiex_free_adapter(adapter);
exit_remove:
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mwifiex_remove_card); EXPORT_SYMBOL_GPL(mwifiex_remove_card);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册