From b21204b60d0149859f2d285b8c2371f40e9bb0e7 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Mon, 29 Jun 2020 13:58:18 +0530 Subject: staging: rts5208/rtsx.c: use generic power management Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200629082819.216405-4-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'drivers/staging/rts5208') diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 937f4e732a75..e28e162d004e 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -258,12 +258,12 @@ static int rtsx_acquire_irq(struct rtsx_dev *dev) return 0; } -#ifdef CONFIG_PM /* * power management */ -static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) +static int __maybe_unused rtsx_suspend(struct device *dev_d) { + struct pci_dev *pci = to_pci_dev(dev_d); struct rtsx_dev *dev = pci_get_drvdata(pci); struct rtsx_chip *chip; @@ -285,10 +285,7 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) if (chip->msi_en) pci_disable_msi(pci); - pci_save_state(pci); - pci_enable_wake(pci, pci_choose_state(pci, state), 1); - pci_disable_device(pci); - pci_set_power_state(pci, pci_choose_state(pci, state)); + device_wakeup_enable(dev_d); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); @@ -296,8 +293,9 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) return 0; } -static int rtsx_resume(struct pci_dev *pci) +static int __maybe_unused rtsx_resume(struct device *dev_d) { + struct pci_dev *pci = to_pci_dev(dev_d); struct rtsx_dev *dev = pci_get_drvdata(pci); struct rtsx_chip *chip; @@ -309,16 +307,6 @@ static int rtsx_resume(struct pci_dev *pci) /* lock the device pointers */ mutex_lock(&dev->dev_mutex); - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(&dev->pci->dev, - "%s: pci_enable_device failed, disabling device\n", - CR_DRIVER_NAME); - /* unlock the device pointers */ - mutex_unlock(&dev->dev_mutex); - return -EIO; - } pci_set_master(pci); if (chip->msi_en) { @@ -340,7 +328,6 @@ static int rtsx_resume(struct pci_dev *pci) return 0; } -#endif /* CONFIG_PM */ static void rtsx_shutdown(struct pci_dev *pci) { @@ -1000,16 +987,15 @@ static const struct pci_device_id rtsx_ids[] = { MODULE_DEVICE_TABLE(pci, rtsx_ids); +static SIMPLE_DEV_PM_OPS(rtsx_pm_ops, rtsx_suspend, rtsx_resume); + /* pci_driver definition */ static struct pci_driver rtsx_driver = { .name = CR_DRIVER_NAME, .id_table = rtsx_ids, .probe = rtsx_probe, .remove = rtsx_remove, -#ifdef CONFIG_PM - .suspend = rtsx_suspend, - .resume = rtsx_resume, -#endif + .driver.pm = &rtsx_pm_ops, .shutdown = rtsx_shutdown, }; -- cgit v1.2.3