Commit f185bcc7 authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by Mark Brown

spi: spi-topcliff-pch: use generic power management

Drivers using legacy PM have to manage PCI states and device's PM states
themselves. They also need to take care of configuration registers.

With improved and powerful support of generic PM, PCI Core takes care of
above mentioned, device-independent, jobs.

This driver makes use of PCI helper functions like
pci_save/restore_state(), pci_enable/disable_device(), pci_enable_wake()
and pci_set_power_state() to do required operations. In generic mode, they
are no longer needed.

Change function parameter in both .suspend() and .resume() to
"struct device*" type. Use dev_get_drvdata() to get drv data.

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Link: https://lore.kernel.org/r/20200720155714.714114-1-vaibhavgupta40@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 47267732
...@@ -1635,64 +1635,39 @@ static void pch_spi_remove(struct pci_dev *pdev) ...@@ -1635,64 +1635,39 @@ static void pch_spi_remove(struct pci_dev *pdev)
kfree(pd_dev_save); kfree(pd_dev_save);
} }
#ifdef CONFIG_PM static int __maybe_unused pch_spi_suspend(struct device *dev)
static int pch_spi_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
int retval; struct pch_pd_dev_save *pd_dev_save = dev_get_drvdata(dev);
struct pch_pd_dev_save *pd_dev_save = pci_get_drvdata(pdev);
dev_dbg(&pdev->dev, "%s ENTRY\n", __func__); dev_dbg(dev, "%s ENTRY\n", __func__);
pd_dev_save->board_dat->suspend_sts = true; pd_dev_save->board_dat->suspend_sts = true;
/* save config space */ return 0;
retval = pci_save_state(pdev);
if (retval == 0) {
pci_enable_wake(pdev, PCI_D3hot, 0);
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
} else {
dev_err(&pdev->dev, "%s pci_save_state failed\n", __func__);
}
return retval;
} }
static int pch_spi_resume(struct pci_dev *pdev) static int __maybe_unused pch_spi_resume(struct device *dev)
{ {
int retval; struct pch_pd_dev_save *pd_dev_save = dev_get_drvdata(dev);
struct pch_pd_dev_save *pd_dev_save = pci_get_drvdata(pdev);
dev_dbg(&pdev->dev, "%s ENTRY\n", __func__);
pci_set_power_state(pdev, PCI_D0); dev_dbg(dev, "%s ENTRY\n", __func__);
pci_restore_state(pdev);
retval = pci_enable_device(pdev); device_wakeup_disable(dev);
if (retval < 0) {
dev_err(&pdev->dev,
"%s pci_enable_device failed\n", __func__);
} else {
pci_enable_wake(pdev, PCI_D3hot, 0);
/* set suspend status to false */ /* set suspend status to false */
pd_dev_save->board_dat->suspend_sts = false; pd_dev_save->board_dat->suspend_sts = false;
}
return retval; return 0;
} }
#else
#define pch_spi_suspend NULL
#define pch_spi_resume NULL
#endif static SIMPLE_DEV_PM_OPS(pch_spi_pm_ops, pch_spi_suspend, pch_spi_resume);
static struct pci_driver pch_spi_pcidev_driver = { static struct pci_driver pch_spi_pcidev_driver = {
.name = "pch_spi", .name = "pch_spi",
.id_table = pch_spi_pcidev_id, .id_table = pch_spi_pcidev_id,
.probe = pch_spi_probe, .probe = pch_spi_probe,
.remove = pch_spi_remove, .remove = pch_spi_remove,
.suspend = pch_spi_suspend, .driver.pm = &pch_spi_pm_ops,
.resume = pch_spi_resume,
}; };
static int __init pch_spi_init(void) static int __init pch_spi_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment