Skip to content

Commit

Permalink
Merge branch 'pci/legacy-pm-removal'
Browse files Browse the repository at this point in the history
- Convert amd64-agp, sis-agp, via-agp from legacy PCI power management to
  generic power management (Vaibhav Gupta)

* pci/legacy-pm-removal:
  via-agp: convert to generic power management
  sis-agp: convert to generic power management
  amd64-agp: convert to generic power management
  • Loading branch information
bjorn-helgaas committed Jan 13, 2022
2 parents 7475f93 + 0aeddbd commit 446cc1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 57 deletions.
24 changes: 6 additions & 18 deletions drivers/char/agp/amd64-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,29 +588,18 @@ static void agp_amd64_remove(struct pci_dev *pdev)
agp_bridges_found--;
}

#ifdef CONFIG_PM
#define agp_amd64_suspend NULL

static int agp_amd64_suspend(struct pci_dev *pdev, pm_message_t state)
static int __maybe_unused agp_amd64_resume(struct device *dev)
{
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));

return 0;
}

static int agp_amd64_resume(struct pci_dev *pdev)
{
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
struct pci_dev *pdev = to_pci_dev(dev);

if (pdev->vendor == PCI_VENDOR_ID_NVIDIA)
nforce3_agp_init(pdev);

return amd_8151_configure();
}

#endif /* CONFIG_PM */

static const struct pci_device_id agp_amd64_pci_table[] = {
{
.class = (PCI_CLASS_BRIDGE_HOST << 8),
Expand Down Expand Up @@ -738,15 +727,14 @@ static const struct pci_device_id agp_amd64_pci_promisc_table[] = {
{ }
};

static SIMPLE_DEV_PM_OPS(agp_amd64_pm_ops, agp_amd64_suspend, agp_amd64_resume);

static struct pci_driver agp_amd64_pci_driver = {
.name = "agpgart-amd64",
.id_table = agp_amd64_pci_table,
.probe = agp_amd64_probe,
.remove = agp_amd64_remove,
#ifdef CONFIG_PM
.suspend = agp_amd64_suspend,
.resume = agp_amd64_resume,
#endif
.driver.pm = &agp_amd64_pm_ops,
};


Expand Down
25 changes: 6 additions & 19 deletions drivers/char/agp/sis-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,14 @@ static void agp_sis_remove(struct pci_dev *pdev)
agp_put_bridge(bridge);
}

#ifdef CONFIG_PM
#define agp_sis_suspend NULL

static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state)
static int __maybe_unused agp_sis_resume(
__attribute__((unused)) struct device *dev)
{
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));

return 0;
}

static int agp_sis_resume(struct pci_dev *pdev)
{
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);

return sis_driver.configure();
}

#endif /* CONFIG_PM */

static const struct pci_device_id agp_sis_pci_table[] = {
{
.class = (PCI_CLASS_BRIDGE_HOST << 8),
Expand Down Expand Up @@ -419,15 +407,14 @@ static const struct pci_device_id agp_sis_pci_table[] = {

MODULE_DEVICE_TABLE(pci, agp_sis_pci_table);

static SIMPLE_DEV_PM_OPS(agp_sis_pm_ops, agp_sis_suspend, agp_sis_resume);

static struct pci_driver agp_sis_pci_driver = {
.name = "agpgart-sis",
.id_table = agp_sis_pci_table,
.probe = agp_sis_probe,
.remove = agp_sis_remove,
#ifdef CONFIG_PM
.suspend = agp_sis_suspend,
.resume = agp_sis_resume,
#endif
.driver.pm = &agp_sis_pm_ops,
};

static int __init agp_sis_init(void)
Expand Down
25 changes: 5 additions & 20 deletions drivers/char/agp/via-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,11 @@ static void agp_via_remove(struct pci_dev *pdev)
agp_put_bridge(bridge);
}

#ifdef CONFIG_PM
#define agp_via_suspend NULL

static int agp_via_suspend(struct pci_dev *pdev, pm_message_t state)
static int __maybe_unused agp_via_resume(struct device *dev)
{
pci_save_state (pdev);
pci_set_power_state (pdev, PCI_D3hot);

return 0;
}

static int agp_via_resume(struct pci_dev *pdev)
{
struct agp_bridge_data *bridge = pci_get_drvdata(pdev);

pci_set_power_state (pdev, PCI_D0);
pci_restore_state(pdev);
struct agp_bridge_data *bridge = dev_get_drvdata(dev);

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

#endif /* CONFIG_PM */

/* must be the same order as name table above */
static const struct pci_device_id agp_via_pci_table[] = {
#define ID(x) \
Expand Down Expand Up @@ -567,16 +554,14 @@ static const struct pci_device_id agp_via_pci_table[] = {

MODULE_DEVICE_TABLE(pci, agp_via_pci_table);

static SIMPLE_DEV_PM_OPS(agp_via_pm_ops, agp_via_suspend, agp_via_resume);

static struct pci_driver agp_via_pci_driver = {
.name = "agpgart-via",
.id_table = agp_via_pci_table,
.probe = agp_via_probe,
.remove = agp_via_remove,
#ifdef CONFIG_PM
.suspend = agp_via_suspend,
.resume = agp_via_resume,
#endif
.driver.pm = &agp_via_pm_ops,
};


Expand Down

0 comments on commit 446cc1c

Please sign in to comment.