Skip to content

Commit 6d1adc3

Browse files
VARoDeKbjorn-helgaas
authored andcommitted
sis-agp: convert to generic power management
Convert sis-agp from legacy PCI power management to the generic power management framework. Previously, sis-agp used legacy PCI power management, and agp_sis_suspend() and agp_sis_resume() were responsible for both device-specific things and generic PCI things: agp_sis_suspend pci_save_state(pdev) <-- generic PCI pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI agp_sis_resume pci_set_power_state(pdev, PCI_D0) <-- generic PCI pci_restore_state(pdev) <-- generic PCI sis_driver.configure() <-- device-specific With generic power management, the PCI bus PM methods do the generic PCI things, and the driver needs only the device-specific part, i.e., suspend_devices_and_enter dpm_suspend_start(PMSG_SUSPEND) pci_pm_suspend # PCI bus .suspend() method agp_sis_suspend <-- not needed at all; removed suspend_enter dpm_suspend_noirq(PMSG_SUSPEND) pci_pm_suspend_noirq # PCI bus .suspend_noirq() method pci_save_state <-- generic PCI pci_prepare_to_sleep <-- generic PCI pci_set_power_state ... dpm_resume_end(PMSG_RESUME) pci_pm_resume # PCI bus .resume() method pci_restore_standard_config pci_set_power_state(PCI_D0) <-- generic PCI pci_restore_state <-- generic PCI agp_sis_resume # dev->driver->pm->resume sis_driver.configure() <-- device-specific [bhelgaas: commit log] Link: https://lore.kernel.org/r/20211208193305.147072-3-helgaas@kernel.org Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Dave Airlie <airlied@redhat.com>
1 parent ec4e4a6 commit 6d1adc3

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

drivers/char/agp/sis-agp.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,14 @@ static void agp_sis_remove(struct pci_dev *pdev)
217217
agp_put_bridge(bridge);
218218
}
219219

220-
#ifdef CONFIG_PM
220+
#define agp_sis_suspend NULL
221221

222-
static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state)
222+
static int __maybe_unused agp_sis_resume(
223+
__attribute__((unused)) struct device *dev)
223224
{
224-
pci_save_state(pdev);
225-
pci_set_power_state(pdev, pci_choose_state(pdev, state));
226-
227-
return 0;
228-
}
229-
230-
static int agp_sis_resume(struct pci_dev *pdev)
231-
{
232-
pci_set_power_state(pdev, PCI_D0);
233-
pci_restore_state(pdev);
234-
235225
return sis_driver.configure();
236226
}
237227

238-
#endif /* CONFIG_PM */
239-
240228
static const struct pci_device_id agp_sis_pci_table[] = {
241229
{
242230
.class = (PCI_CLASS_BRIDGE_HOST << 8),
@@ -419,15 +407,14 @@ static const struct pci_device_id agp_sis_pci_table[] = {
419407

420408
MODULE_DEVICE_TABLE(pci, agp_sis_pci_table);
421409

410+
static SIMPLE_DEV_PM_OPS(agp_sis_pm_ops, agp_sis_suspend, agp_sis_resume);
411+
422412
static struct pci_driver agp_sis_pci_driver = {
423413
.name = "agpgart-sis",
424414
.id_table = agp_sis_pci_table,
425415
.probe = agp_sis_probe,
426416
.remove = agp_sis_remove,
427-
#ifdef CONFIG_PM
428-
.suspend = agp_sis_suspend,
429-
.resume = agp_sis_resume,
430-
#endif
417+
.driver.pm = &agp_sis_pm_ops,
431418
};
432419

433420
static int __init agp_sis_init(void)

0 commit comments

Comments
 (0)