Skip to content

Commit 0aeddbd

Browse files
VARoDeKbjorn-helgaas
authored andcommitted
via-agp: convert to generic power management
Convert via-agp from legacy PCI power management to the generic power management framework. Previously, via-agp used legacy PCI power management, and agp_via_suspend() and agp_via_resume() were responsible for both device-specific things and generic PCI things: agp_via_suspend pci_save_state(pdev) <-- generic PCI pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI agp_via_resume pci_set_power_state(pdev, PCI_D0) <-- generic PCI pci_restore_state(pdev) <-- generic PCI via_configure_agp3() <-- device-specific via_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_via_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_via_resume # dev->driver->pm->resume via_configure_agp3() <-- device-specific via_configure() <-- device-specific [bhelgaas: commit log] Link: https://lore.kernel.org/r/20211208193305.147072-4-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 6d1adc3 commit 0aeddbd

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

drivers/char/agp/via-agp.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,11 @@ static void agp_via_remove(struct pci_dev *pdev)
492492
agp_put_bridge(bridge);
493493
}
494494

495-
#ifdef CONFIG_PM
495+
#define agp_via_suspend NULL
496496

497-
static int agp_via_suspend(struct pci_dev *pdev, pm_message_t state)
497+
static int __maybe_unused agp_via_resume(struct device *dev)
498498
{
499-
pci_save_state (pdev);
500-
pci_set_power_state (pdev, PCI_D3hot);
501-
502-
return 0;
503-
}
504-
505-
static int agp_via_resume(struct pci_dev *pdev)
506-
{
507-
struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
508-
509-
pci_set_power_state (pdev, PCI_D0);
510-
pci_restore_state(pdev);
499+
struct agp_bridge_data *bridge = dev_get_drvdata(dev);
511500

512501
if (bridge->driver == &via_agp3_driver)
513502
return via_configure_agp3();
@@ -517,8 +506,6 @@ static int agp_via_resume(struct pci_dev *pdev)
517506
return 0;
518507
}
519508

520-
#endif /* CONFIG_PM */
521-
522509
/* must be the same order as name table above */
523510
static const struct pci_device_id agp_via_pci_table[] = {
524511
#define ID(x) \
@@ -567,16 +554,14 @@ static const struct pci_device_id agp_via_pci_table[] = {
567554

568555
MODULE_DEVICE_TABLE(pci, agp_via_pci_table);
569556

557+
static SIMPLE_DEV_PM_OPS(agp_via_pm_ops, agp_via_suspend, agp_via_resume);
570558

571559
static struct pci_driver agp_via_pci_driver = {
572560
.name = "agpgart-via",
573561
.id_table = agp_via_pci_table,
574562
.probe = agp_via_probe,
575563
.remove = agp_via_remove,
576-
#ifdef CONFIG_PM
577-
.suspend = agp_via_suspend,
578-
.resume = agp_via_resume,
579-
#endif
564+
.driver.pm = &agp_via_pm_ops,
580565
};
581566

582567

0 commit comments

Comments
 (0)