diff options
author | Vaibhav Gupta <vaibhavgupta40@gmail.com> | 2020-06-29 11:15:31 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-06-29 19:43:42 +0300 |
commit | 34afa1d657d4742c9bce4a4c197ebf61b4af1b9e (patch) | |
tree | e83dc84729f0c08fd437b558ee303d48c2c567a4 /drivers/misc | |
parent | 6bbf52566bf7cb26546ec9d9aa76a3cb80d4eb18 (diff) | |
download | linux-34afa1d657d4742c9bce4a4c197ebf61b4af1b9e.tar.xz |
misc/pch_phub.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. It was also saving device register
configuration using pch_phub_save/restore_reg_conf() which is not
recommended.
Compile-tested only.
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Link: https://lore.kernel.org/r/20200629081531.214734-6-vaibhavgupta40@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/pch_phub.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 60828af7506a..9321d4239932 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c @@ -147,9 +147,8 @@ static void pch_phub_read_modify_write_reg(struct pch_phub_reg *chip, iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr); } -#ifdef CONFIG_PM /* pch_phub_save_reg_conf - saves register configuration */ -static void pch_phub_save_reg_conf(struct pci_dev *pdev) +static void __maybe_unused pch_phub_save_reg_conf(struct pci_dev *pdev) { unsigned int i; struct pch_phub_reg *chip = pci_get_drvdata(pdev); @@ -210,7 +209,7 @@ static void pch_phub_save_reg_conf(struct pci_dev *pdev) } /* pch_phub_restore_reg_conf - restore register configuration */ -static void pch_phub_restore_reg_conf(struct pci_dev *pdev) +static void __maybe_unused pch_phub_restore_reg_conf(struct pci_dev *pdev) { unsigned int i; struct pch_phub_reg *chip = pci_get_drvdata(pdev); @@ -270,7 +269,6 @@ static void pch_phub_restore_reg_conf(struct pci_dev *pdev) if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); } -#endif /** * pch_phub_read_serial_rom() - Reading Serial ROM @@ -835,48 +833,19 @@ static void pch_phub_remove(struct pci_dev *pdev) kfree(chip); } -#ifdef CONFIG_PM - -static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused pch_phub_suspend(struct device *dev_d) { - int ret; - - pch_phub_save_reg_conf(pdev); - ret = pci_save_state(pdev); - if (ret) { - dev_err(&pdev->dev, - " %s -pci_save_state returns %d\n", __func__, ret); - return ret; - } - pci_enable_wake(pdev, PCI_D3hot, 0); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + device_wakeup_disable(dev_d); return 0; } -static int pch_phub_resume(struct pci_dev *pdev) +static int __maybe_unused pch_phub_resume(struct device *dev_d) { - int ret; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, - "%s-pci_enable_device failed(ret=%d) ", __func__, ret); - return ret; - } - - pci_enable_wake(pdev, PCI_D3hot, 0); - pch_phub_restore_reg_conf(pdev); + device_wakeup_disable(dev_d); return 0; } -#else -#define pch_phub_suspend NULL -#define pch_phub_resume NULL -#endif /* CONFIG_PM */ static const struct pci_device_id pch_phub_pcidev_id[] = { { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, }, @@ -888,13 +857,14 @@ static const struct pci_device_id pch_phub_pcidev_id[] = { }; MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id); +static SIMPLE_DEV_PM_OPS(pch_phub_pm_ops, pch_phub_suspend, pch_phub_resume); + static struct pci_driver pch_phub_driver = { .name = "pch_phub", .id_table = pch_phub_pcidev_id, .probe = pch_phub_probe, .remove = pch_phub_remove, - .suspend = pch_phub_suspend, - .resume = pch_phub_resume + .driver.pm = &pch_phub_pm_ops, }; module_pci_driver(pch_phub_driver); |