HID: amd_sfh: Add support for shutdown operation
authorBasavaraj Natikar <Basavaraj.Natikar@amd.com>
Tue, 11 Apr 2023 16:10:27 +0000 (21:40 +0530)
committerJiri Kosina <jkosina@suse.cz>
Thu, 13 Apr 2023 13:55:22 +0000 (15:55 +0200)
As soon as the system is booted after shutdown, the sensors may remain in
a weird state and fail to initialize. Therefore, all sensors should be
turned off during shutdown.

Fixes: 4f567b9f8141 ("SFH: PCIe driver to add support of AMD sensor fusion hub")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

index 47774b9ab3de0fc85b6ea922db059fcdb4ebe2c8..c936d6a51c0cd6750d8f46c9a831d9655d9e3335 100644 (file)
@@ -367,6 +367,14 @@ init_done:
        return devm_add_action_or_reset(&pdev->dev, privdata->mp2_ops->remove, privdata);
 }
 
+static void amd_sfh_shutdown(struct pci_dev *pdev)
+{
+       struct amd_mp2_dev *mp2 = pci_get_drvdata(pdev);
+
+       if (mp2 && mp2->mp2_ops)
+               mp2->mp2_ops->stop_all(mp2);
+}
+
 static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
 {
        struct amd_mp2_dev *mp2 = dev_get_drvdata(dev);
@@ -401,6 +409,7 @@ static struct pci_driver amd_mp2_pci_driver = {
        .id_table       = amd_mp2_pci_tbl,
        .probe          = amd_mp2_pci_probe,
        .driver.pm      = &amd_mp2_pm_ops,
+       .shutdown       = amd_sfh_shutdown,
 };
 module_pci_driver(amd_mp2_pci_driver);