drivers/net: don't use flush_scheduled_work()
authorTejun Heo <tj@kernel.org>
Sun, 12 Dec 2010 15:45:14 +0000 (16:45 +0100)
committerTejun Heo <tj@kernel.org>
Sun, 12 Dec 2010 15:45:14 +0000 (16:45 +0100)
flush_scheduled_work() is on its way out.  This patch contains simple
conversions to replace flush_scheduled_work() usage with direct
cancels and flushes.

Directly cancel the used works on driver detach and flush them in
other cases.

The conversions are mostly straight forward and the only dangers are,

* Forgetting to cancel/flush one or more used works.

* Cancelling when a work should be flushed (ie. the work must be
  executed once scheduled whether the driver is detaching or not).

I've gone over the changes multiple times but it would be much
appreciated if you can review with the above points in mind.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jay Cliburn <jcliburn@gmail.com>
Cc: Michael Chan <mchan@broadcom.com>
Cc: Divy Le Ray <divy@chelsio.com>
Cc: e1000-devel@lists.sourceforge.net
Cc: Vasanthy Kolluri <vkolluri@cisco.com>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: Lennert Buytenhek <buytenh@wantstofly.org>
Cc: Andrew Gallatin <gallatin@myri.com>
Cc: Francois Romieu <romieu@fr.zoreil.com>
Cc: Ramkrishna Vepa <ramkrishna.vepa@exar.com>
Cc: Matt Carlson <mcarlson@broadcom.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Shreyas Bhatewara <sbhatewara@vmware.com>
Cc: netdev@vger.kernel.org
23 files changed:
drivers/net/8139too.c
drivers/net/atlx/atl2.c
drivers/net/bcm63xx_enet.c
drivers/net/bnx2.c
drivers/net/cassini.c
drivers/net/cxgb3/cxgb3_main.c
drivers/net/e1000e/netdev.c
drivers/net/enic/enic_main.c
drivers/net/ibm_newemac/core.c
drivers/net/irda/mcs7780.c
drivers/net/ixgb/ixgb_main.c
drivers/net/ixgbevf/ixgbevf_main.c
drivers/net/mv643xx_eth.c
drivers/net/myri10ge/myri10ge.c
drivers/net/niu.c
drivers/net/pxa168_eth.c
drivers/net/r8169.c
drivers/net/s2io.c
drivers/net/sis190.c
drivers/net/tg3.c
drivers/net/usb/sierra_net.c
drivers/net/usb/usbnet.c
drivers/net/vmxnet3/vmxnet3_drv.c

index f5166dccd8dfa6b0436eb6397b20e7f05adee58e..98517a373473e18b1a9f6982407831580079263a 100644 (file)
@@ -1092,10 +1092,11 @@ err_out:
 static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
+       struct rtl8139_private *tp = netdev_priv(dev);
 
        assert (dev != NULL);
 
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&tp->thread);
 
        unregister_netdev (dev);
 
index 35b14bec12078a1a8cf364da39290d56429339b5..4e6f4e95a5a03342320ee24cbe70bfa1365c7b3a 100644 (file)
@@ -1504,8 +1504,8 @@ static void __devexit atl2_remove(struct pci_dev *pdev)
 
        del_timer_sync(&adapter->watchdog_timer);
        del_timer_sync(&adapter->phy_config_timer);
-
-       flush_scheduled_work();
+       cancel_work_sync(&adapter->reset_task);
+       cancel_work_sync(&adapter->link_chg_task);
 
        unregister_netdev(netdev);
 
index ecfef240a303039390088f59b6425747377f1cdc..e94a966af4186bb4db195547ac7ddc7ac957ea1f 100644 (file)
@@ -1097,7 +1097,7 @@ static int bcm_enet_stop(struct net_device *dev)
        enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->tx_chan));
 
        /* make sure no mib update is scheduled */
-       flush_scheduled_work();
+       cancel_work_sync(&priv->mib_update_task);
 
        /* disable dma & mac */
        bcm_enet_disable_dma(priv, priv->tx_chan);
index 03209a37883e35dc72615e4927a32eb4900b459c..5c811f3fa11abbbe59789bed4650a4ca41019710 100644 (file)
@@ -8393,7 +8393,7 @@ bnx2_remove_one(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = netdev_priv(dev);
 
-       flush_scheduled_work();
+       cancel_work_sync(&bp->reset_task);
 
        unregister_netdev(dev);
 
@@ -8431,7 +8431,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
        if (!netif_running(dev))
                return 0;
 
-       flush_scheduled_work();
+       cancel_work_sync(&bp->reset_task);
        bnx2_netif_stop(bp, true);
        netif_device_detach(dev);
        del_timer_sync(&bp->timer);
index d6b6d6aa565a377f368d15ac4aef1faab23267b1..a8a32bc9aae6cf88e99106c86b523b23942828ac 100644 (file)
@@ -3880,7 +3880,7 @@ static int cas_change_mtu(struct net_device *dev, int new_mtu)
        schedule_work(&cp->reset_task);
 #endif
 
-       flush_scheduled_work();
+       flush_work_sync(&cp->reset_task);
        return 0;
 }
 
@@ -5177,7 +5177,7 @@ static void __devexit cas_remove_one(struct pci_dev *pdev)
                vfree(cp->fw_data);
 
        mutex_lock(&cp->pm_mutex);
-       flush_scheduled_work();
+       cancel_work_sync(&cp->reset_task);
        if (cp->hw_running)
                cas_shutdown(cp);
        mutex_unlock(&cp->pm_mutex);
index 386461750d0f8508cea96295ef22a1513bb07c22..4d538a4e9d553389c99b95fdd02ce9170438766f 100644 (file)
@@ -1359,6 +1359,7 @@ out:
 static int offload_close(struct t3cdev *tdev)
 {
        struct adapter *adapter = tdev2adap(tdev);
+       struct t3c_data *td = T3C_DATA(tdev);
 
        if (!test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map))
                return 0;
@@ -1369,7 +1370,7 @@ static int offload_close(struct t3cdev *tdev)
        sysfs_remove_group(&tdev->lldev->dev.kobj, &offload_attr_group);
 
        /* Flush work scheduled while releasing TIDs */
-       flush_scheduled_work();
+       flush_work_sync(&td->tid_release_task);
 
        tdev->lldev = NULL;
        cxgb3_set_dummy_ops(tdev);
index 5530d0bdd11ab33353063d00e9c679aaf69e55fe..02d093d1dd5c48ca273bbb73c00cd1bdbed894af 100644 (file)
@@ -6028,8 +6028,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        bool down = test_bit(__E1000_DOWN, &adapter->state);
 
        /*
-        * flush_scheduled work may reschedule our watchdog task, so
-        * explicitly disable watchdog tasks from being rescheduled
+        * The timers may be rescheduled, so explicitly disable them
+        * from being rescheduled.
         */
        if (!down)
                set_bit(__E1000_DOWN, &adapter->state);
@@ -6040,8 +6040,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        cancel_work_sync(&adapter->watchdog_task);
        cancel_work_sync(&adapter->downshift_task);
        cancel_work_sync(&adapter->update_phy_task);
+       cancel_work_sync(&adapter->led_blink_task);
        cancel_work_sync(&adapter->print_hang_task);
-       flush_scheduled_work();
 
        if (!(netdev->flags & IFF_UP))
                e1000_power_down_phy(adapter);
index 9befd54ce6e1b9886ce8c0cb8370ce538e3f3527..77d91381a74d2bb33cd6420c27f33a9b7ed145a5 100644 (file)
@@ -2834,7 +2834,7 @@ static void __devexit enic_remove(struct pci_dev *pdev)
        if (netdev) {
                struct enic *enic = netdev_priv(netdev);
 
-               flush_scheduled_work();
+               cancel_work_sync(&enic->reset);
                unregister_netdev(netdev);
                enic_dev_deinit(enic);
                vnic_dev_close(enic->vdev);
index 06bb9b7994585318bb723046a0804a39a4a4a5e8..8f11d29a5828227d29d596d0c484f312a81a4978 100644 (file)
@@ -2950,7 +2950,7 @@ static int __devexit emac_remove(struct platform_device *ofdev)
 
        unregister_netdev(dev->ndev);
 
-       flush_scheduled_work();
+       cancel_work_sync(&dev->reset_work);
 
        if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
                tah_detach(dev->tah_dev, dev->tah_port);
index 74b20f179cea029be0f2767fac5e3b04cee987a6..cc821de2c9669bb5c9e17bda80e3d98372c9d9f0 100644 (file)
@@ -959,7 +959,7 @@ static void mcs_disconnect(struct usb_interface *intf)
        if (!mcs)
                return;
 
-       flush_scheduled_work();
+       cancel_work_sync(&mcs->work);
 
        unregister_netdev(mcs->netdev);
        free_netdev(mcs->netdev);
index 2e98506d12e32753b2f85897f7ece74bf5ede35a..b021798ef49f847c9234186b7cb7639c82916a80 100644 (file)
@@ -527,7 +527,7 @@ ixgb_remove(struct pci_dev *pdev)
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct ixgb_adapter *adapter = netdev_priv(netdev);
 
-       flush_scheduled_work();
+       cancel_work_sync(&adapter->tx_timeout_task);
 
        unregister_netdev(netdev);
 
index 2216a3c8b12bf30ba0a078ec87c55c9993d589c0..809e38ce8a13bbfe8ded581f5de714788f6ef542 100644 (file)
@@ -3484,10 +3484,9 @@ static void __devexit ixgbevf_remove(struct pci_dev *pdev)
 
        del_timer_sync(&adapter->watchdog_timer);
 
+       cancel_work_sync(&adapter->reset_task);
        cancel_work_sync(&adapter->watchdog_task);
 
-       flush_scheduled_work();
-
        if (adapter->netdev_registered) {
                unregister_netdev(netdev);
                adapter->netdev_registered = false;
index ce31e74a559bc4110ad4c82371adfcbcbc38b644..02076e16542a30b2a4e98e5debd667c53eea77e3 100644 (file)
@@ -2978,7 +2978,7 @@ static int mv643xx_eth_remove(struct platform_device *pdev)
        unregister_netdev(mp->dev);
        if (mp->phy != NULL)
                phy_detach(mp->phy);
-       flush_scheduled_work();
+       cancel_work_sync(&mp->tx_timeout_task);
        free_netdev(mp->dev);
 
        platform_set_drvdata(pdev, NULL);
index 8524cc40ec57b8beb86b1bed83b5e7677487172c..1ce0207e62a945f085a6e2153c1b1c1735afdfd3 100644 (file)
@@ -4067,7 +4067,7 @@ static void myri10ge_remove(struct pci_dev *pdev)
        if (mgp == NULL)
                return;
 
-       flush_scheduled_work();
+       cancel_work_sync(&mgp->watchdog_work);
        netdev = mgp->dev;
        unregister_netdev(netdev);
 
index 781e368329f91efe26389c17e0b293bb4342fcde..f64c42414bd752b713df5a0534d29437f5d55d97 100644 (file)
@@ -9917,7 +9917,7 @@ static int niu_suspend(struct pci_dev *pdev, pm_message_t state)
        if (!netif_running(dev))
                return 0;
 
-       flush_scheduled_work();
+       flush_work_sync(&np->reset_task);
        niu_netif_stop(np);
 
        del_timer_sync(&np->timer);
index 04ed27d0b6bebb3df8938dbf97d668a8bb347e99..1b63c8aef121cb6dd723e08c69cbfa4c334f698b 100644 (file)
@@ -1602,7 +1602,7 @@ static int pxa168_eth_remove(struct platform_device *pdev)
        mdiobus_unregister(pep->smi_bus);
        mdiobus_free(pep->smi_bus);
        unregister_netdev(dev);
-       flush_scheduled_work();
+       cancel_work_sync(&pep->tx_timeout_task);
        free_netdev(dev);
        platform_set_drvdata(pdev, NULL);
        return 0;
index 7d33ef4bcb4a1d6ca7125d6780e173889ebbb0d8..98d792c3387707f86518bbf65e1006a81cf14091 100644 (file)
@@ -3240,7 +3240,7 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct rtl8169_private *tp = netdev_priv(dev);
 
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&tp->task);
 
        unregister_netdev(dev);
 
index 9a1e32fb720bdcddbc6338a9decfbfd54c9516cf..39c17cecb8b98f5258bd9245ad451b14d6b2473b 100644 (file)
@@ -8341,9 +8341,11 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
                return;
        }
 
-       flush_scheduled_work();
-
        sp = netdev_priv(dev);
+
+       cancel_work_sync(&sp->rst_timer_task);
+       cancel_work_sync(&sp->set_link_task);
+
        unregister_netdev(dev);
 
        free_shared_mem(sp);
index a5d6a6bd0c1adfae58469ab7f08fe56e14e17d9f..3406ed8709176eefebd268fb66bb82b168c8410b 100644 (file)
@@ -1915,9 +1915,10 @@ err_release_board:
 static void __devexit sis190_remove_one(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
+       struct sis190_private *tp = netdev_priv(dev);
 
        sis190_mii_remove(dev);
-       flush_scheduled_work();
+       cancel_work_sync(&tp->phy_task);
        unregister_netdev(dev);
        sis190_release_board(pdev);
        pci_set_drvdata(pdev, NULL);
index 5faa87d86c6667fed06e5b7aa9a7ce9610d23bab..57e19fb1324f1eeab8cc17ad0181361dc8db5ec5 100644 (file)
@@ -15034,7 +15034,7 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
                if (tp->fw)
                        release_firmware(tp->fw);
 
-               flush_scheduled_work();
+               cancel_work_sync(&tp->reset_task);
 
                if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
                        tg3_phy_fini(tp);
@@ -15073,7 +15073,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
        if (!netif_running(dev))
                return 0;
 
-       flush_scheduled_work();
+       flush_work_sync(&tp->reset_task);
        tg3_phy_stop(tp);
        tg3_netif_stop(tp);
 
index d1ac15c95faf6d00803a67c7e4c9294e8299984f..ed1b4321058487a62530442586d7f0c2f7628dff 100644 (file)
@@ -802,10 +802,9 @@ static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
 
        dev_dbg(&dev->udev->dev, "%s", __func__);
 
-       /* Kill the timer then flush the work queue */
+       /* kill the timer and work */
        del_timer_sync(&priv->sync_timer);
-
-       flush_scheduled_work();
+       cancel_work_sync(&priv->sierra_net_kevent);
 
        /* tell modem we are going away */
        status = sierra_net_send_cmd(dev, priv->shdwn_msg,
index cff74b81a7d2ccfdb566ea16901a2076d78964e5..ed9a41643ff41f26afe6b6c4f8916137f4baed0d 100644 (file)
@@ -1248,8 +1248,7 @@ void usbnet_disconnect (struct usb_interface *intf)
        net = dev->net;
        unregister_netdev (net);
 
-       /* we don't hold rtnl here ... */
-       flush_scheduled_work ();
+       cancel_work_sync(&dev->kevent);
 
        if (dev->driver_info->unbind)
                dev->driver_info->unbind (dev, intf);
index 65860a998321204770b2e203132782bd60559782..0169be7694a94a6cbfb0f8870536e374dd8034e3 100644 (file)
@@ -3069,7 +3069,7 @@ vmxnet3_remove_device(struct pci_dev *pdev)
 #endif
                num_rx_queues = 1;
 
-       flush_scheduled_work();
+       cancel_work_sync(&adapter->work);
 
        unregister_netdev(netdev);