mei: add pci driver ops shutdown handler.
authorTomas Winkler <tomas.winkler@intel.com>
Mon, 20 Mar 2017 13:04:02 +0000 (15:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Apr 2017 15:38:25 +0000 (17:38 +0200)
The shutdown handler quiesces the device, it performs link reset in
order to close all connections and notify the device that is not longer
managed by the driver.
This is essentially a stripped down version of the PCI remove() function
where only the necessary amount of work is done to stop any further
activity.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/pci-me.c
drivers/misc/mei/pci-txe.c

index 0a668fd..8621a19 100644 (file)
@@ -242,11 +242,38 @@ end:
 }
 
 /**
+ * mei_me_shutdown - Device Removal Routine
+ *
+ * @pdev: PCI device structure
+ *
+ * mei_me_shutdown is called from the reboot notifier
+ * it's a simplified version of remove so we go down
+ * faster.
+ */
+static void mei_me_shutdown(struct pci_dev *pdev)
+{
+       struct mei_device *dev;
+
+       dev = pci_get_drvdata(pdev);
+       if (!dev)
+               return;
+
+       dev_dbg(&pdev->dev, "shutdown\n");
+       mei_stop(dev);
+
+       if (!pci_dev_run_wake(pdev))
+               mei_me_unset_pm_domain(dev);
+
+       mei_disable_interrupts(dev);
+       free_irq(pdev->irq, dev);
+}
+
+/**
  * mei_me_remove - Device Removal Routine
  *
  * @pdev: PCI device structure
  *
- * mei_remove is called by the PCI subsystem to alert the driver
+ * mei_me_remove is called by the PCI subsystem to alert the driver
  * that it should release a PCI device.
  */
 static void mei_me_remove(struct pci_dev *pdev)
@@ -456,7 +483,7 @@ static struct pci_driver mei_me_driver = {
        .id_table = mei_me_pci_tbl,
        .probe = mei_me_probe,
        .remove = mei_me_remove,
-       .shutdown = mei_me_remove,
+       .shutdown = mei_me_shutdown,
        .driver.pm = MEI_ME_PM_OPS,
 };
 
index fe088b4..f811cd5 100644 (file)
@@ -161,6 +161,33 @@ end:
 }
 
 /**
+ * mei_txe_remove - Device Shutdown Routine
+ *
+ * @pdev: PCI device structure
+ *
+ *  mei_txe_shutdown is called from the reboot notifier
+ *  it's a simplified version of remove so we go down
+ *  faster.
+ */
+static void mei_txe_shutdown(struct pci_dev *pdev)
+{
+       struct mei_device *dev;
+
+       dev = pci_get_drvdata(pdev);
+       if (!dev)
+               return;
+
+       dev_dbg(&pdev->dev, "shutdown\n");
+       mei_stop(dev);
+
+       if (!pci_dev_run_wake(pdev))
+               mei_txe_unset_pm_domain(dev);
+
+       mei_disable_interrupts(dev);
+       free_irq(pdev->irq, dev);
+}
+
+/**
  * mei_txe_remove - Device Removal Routine
  *
  * @pdev: PCI device structure
@@ -386,7 +413,7 @@ static struct pci_driver mei_txe_driver = {
        .id_table = mei_txe_pci_tbl,
        .probe = mei_txe_probe,
        .remove = mei_txe_remove,
-       .shutdown = mei_txe_remove,
+       .shutdown = mei_txe_shutdown,
        .driver.pm = MEI_TXE_PM_OPS,
 };