kfree(mem->va);
 }
 
-/**
- * iavf_lock_timeout - try to lock mutex but give up after timeout
- * @lock: mutex that should be locked
- * @msecs: timeout in msecs
- *
- * Returns 0 on success, negative on failure
- **/
-static int iavf_lock_timeout(struct mutex *lock, unsigned int msecs)
-{
-       unsigned int wait, delay = 10;
-
-       for (wait = 0; wait < msecs; wait += delay) {
-               if (mutex_trylock(lock))
-                       return 0;
-
-               msleep(delay);
-       }
-
-       return -1;
-}
-
 /**
  * iavf_schedule_reset - Set the flags and schedule a reset event
  * @adapter: board private structure
        return 0;
 }
 
-/**
- * iavf_shutdown - Shutdown the device in preparation for a reboot
- * @pdev: pci device structure
- **/
-static void iavf_shutdown(struct pci_dev *pdev)
-{
-       struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
-       struct net_device *netdev = adapter->netdev;
-
-       netif_device_detach(netdev);
-
-       if (netif_running(netdev))
-               iavf_close(netdev);
-
-       if (iavf_lock_timeout(&adapter->crit_lock, 5000))
-               dev_warn(&adapter->pdev->dev, "%s: failed to acquire crit_lock\n", __func__);
-       /* Prevent the watchdog from running. */
-       iavf_change_state(adapter, __IAVF_REMOVE);
-       adapter->aq_required = 0;
-       mutex_unlock(&adapter->crit_lock);
-
-#ifdef CONFIG_PM
-       pci_save_state(pdev);
-
-#endif
-       pci_disable_device(pdev);
-}
-
 /**
  * iavf_probe - Device Initialization Routine
  * @pdev: PCI device information struct
  **/
 static void iavf_remove(struct pci_dev *pdev)
 {
-       struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
        struct iavf_fdir_fltr *fdir, *fdirtmp;
        struct iavf_vlan_filter *vlf, *vlftmp;
        struct iavf_cloud_filter *cf, *cftmp;
        struct iavf_adv_rss *rss, *rsstmp;
        struct iavf_mac_filter *f, *ftmp;
+       struct iavf_adapter *adapter;
        struct net_device *netdev;
        struct iavf_hw *hw;
 
-       netdev = adapter->netdev;
+       /* Don't proceed with remove if netdev is already freed */
+       netdev = pci_get_drvdata(pdev);
+       if (!netdev)
+               return;
+
+       adapter = iavf_pdev_to_adapter(pdev);
        hw = &adapter->hw;
 
        if (test_and_set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section))
 
        destroy_workqueue(adapter->wq);
 
+       pci_set_drvdata(pdev, NULL);
+
        free_netdev(netdev);
 
        pci_disable_device(pdev);
 }
 
+/**
+ * iavf_shutdown - Shutdown the device in preparation for a reboot
+ * @pdev: pci device structure
+ **/
+static void iavf_shutdown(struct pci_dev *pdev)
+{
+       iavf_remove(pdev);
+
+       if (system_state == SYSTEM_POWER_OFF)
+               pci_set_power_state(pdev, PCI_D3hot);
+}
+
 static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);
 
 static struct pci_driver iavf_driver = {