diff options
Diffstat (limited to 'drivers/video/fbdev/savage')
-rw-r--r-- | drivers/video/fbdev/savage/savagefb_driver.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 661398e40ff4..0ac750cc5ea1 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -2347,9 +2347,9 @@ static void savagefb_remove(struct pci_dev *dev) } } -static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) +static int savagefb_suspend_late(struct device *dev, pm_message_t mesg) { - struct fb_info *info = pci_get_drvdata(dev); + struct fb_info *info = dev_get_drvdata(dev); struct savagefb_par *par = info->par; DBG("savagefb_suspend"); @@ -2357,7 +2357,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) if (mesg.event == PM_EVENT_PRETHAW) mesg.event = PM_EVENT_FREEZE; par->pm_state = mesg.event; - dev->dev.power.power_state = mesg; + dev->power.power_state = mesg; /* * For PM_EVENT_FREEZE, do not power down so the console @@ -2375,17 +2375,29 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) savagefb_blank(FB_BLANK_POWERDOWN, info); savage_set_default_par(par, &par->save); savage_disable_mmio(par); - pci_save_state(dev); - pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, mesg)); console_unlock(); return 0; } -static int savagefb_resume(struct pci_dev* dev) +static int __maybe_unused savagefb_suspend(struct device *dev) { - struct fb_info *info = pci_get_drvdata(dev); + return savagefb_suspend_late(dev, PMSG_SUSPEND); +} + +static int __maybe_unused savagefb_hibernate(struct device *dev) +{ + return savagefb_suspend_late(dev, PMSG_HIBERNATE); +} + +static int __maybe_unused savagefb_freeze(struct device *dev) +{ + return savagefb_suspend_late(dev, PMSG_FREEZE); +} + +static int __maybe_unused savagefb_resume(struct device *dev) +{ + struct fb_info *info = dev_get_drvdata(dev); struct savagefb_par *par = info->par; int cur_state = par->pm_state; @@ -2397,20 +2409,11 @@ static int savagefb_resume(struct pci_dev* dev) * The adapter was not powered down coming back from a * PM_EVENT_FREEZE. */ - if (cur_state == PM_EVENT_FREEZE) { - pci_set_power_state(dev, PCI_D0); + if (cur_state == PM_EVENT_FREEZE) return 0; - } console_lock(); - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - - if (pci_enable_device(dev)) - DBG("err"); - - pci_set_master(dev); savage_enable_mmio(par); savage_init_hw(par); savagefb_set_par(info); @@ -2421,6 +2424,16 @@ static int savagefb_resume(struct pci_dev* dev) return 0; } +static const struct dev_pm_ops savagefb_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = savagefb_suspend, + .resume = savagefb_resume, + .freeze = savagefb_freeze, + .thaw = savagefb_resume, + .poweroff = savagefb_hibernate, + .restore = savagefb_resume, +#endif +}; static const struct pci_device_id savagefb_devices[] = { {PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX128, @@ -2501,8 +2514,7 @@ static struct pci_driver savagefb_driver = { .name = "savagefb", .id_table = savagefb_devices, .probe = savagefb_probe, - .suspend = savagefb_suspend, - .resume = savagefb_resume, + .driver.pm = &savagefb_pm_ops, .remove = savagefb_remove, }; |