Commit d67e37d7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jesse Barnes

PCI PM: Run default PM callbacks for all devices using new framework

It should be quite clear that it generally makes sense to execute
the default PM callbacks (ie. the callbacks used for handling
suspend, hibernation and resume of PCI devices without drivers) for
all devices.  Of course, the drivers that provide legacy PCI PM
support (ie. the ->suspend, ->suspend_late, ->resume_early
or ->resume hooks in the pci_driver structure), carry out these
operations too, so we can't do it for devices with such drivers.
Still, we can make the default PM callbacks run for devices with
drivers using the new framework (ie. implement the pm object), since
there are no such drivers at the moment.

This also simplifies the code and makes it smaller.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@suse.cz>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 98e6e286
...@@ -486,6 +486,8 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev) ...@@ -486,6 +486,8 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev)
if (!pci_is_bridge(pci_dev)) if (!pci_is_bridge(pci_dev))
pci_prepare_to_sleep(pci_dev); pci_prepare_to_sleep(pci_dev);
pci_fixup_device(pci_fixup_suspend, pci_dev);
} }
static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
...@@ -536,16 +538,13 @@ static int pci_pm_suspend(struct device *dev) ...@@ -536,16 +538,13 @@ static int pci_pm_suspend(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_SUSPEND); return pci_legacy_suspend(dev, PMSG_SUSPEND);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->suspend) {
if (drv->pm->suspend) {
error = drv->pm->suspend(dev); error = drv->pm->suspend(dev);
suspend_report_result(drv->pm->suspend, error); suspend_report_result(drv->pm->suspend, error);
} }
} else {
pci_pm_default_suspend(pci_dev);
}
pci_fixup_device(pci_fixup_suspend, pci_dev); if (!error)
pci_pm_default_suspend(pci_dev);
return error; return error;
} }
...@@ -559,14 +558,13 @@ static int pci_pm_suspend_noirq(struct device *dev) ...@@ -559,14 +558,13 @@ static int pci_pm_suspend_noirq(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend_late(dev, PMSG_SUSPEND); return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->suspend_noirq) {
if (drv->pm->suspend_noirq) {
error = drv->pm->suspend_noirq(dev); error = drv->pm->suspend_noirq(dev);
suspend_report_result(drv->pm->suspend_noirq, error); suspend_report_result(drv->pm->suspend_noirq, error);
} }
} else {
if (!error)
pci_pm_set_unknown_state(pci_dev); pci_pm_set_unknown_state(pci_dev);
}
return error; return error;
} }
...@@ -580,14 +578,10 @@ static int pci_pm_resume(struct device *dev) ...@@ -580,14 +578,10 @@ static int pci_pm_resume(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume(dev); return pci_legacy_resume(dev);
if (drv && drv->pm) { error = pci_pm_default_resume(pci_dev);
pci_fixup_device(pci_fixup_resume, pci_dev);
if (drv->pm->resume) if (!error && drv && drv->pm && drv->pm->resume)
error = drv->pm->resume(dev); error = drv->pm->resume(dev);
} else {
error = pci_pm_default_resume(pci_dev);
}
return error; return error;
} }
...@@ -601,14 +595,10 @@ static int pci_pm_resume_noirq(struct device *dev) ...@@ -601,14 +595,10 @@ static int pci_pm_resume_noirq(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev); return pci_legacy_resume_early(dev);
if (drv && drv->pm) { pci_pm_default_resume_noirq(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (drv->pm->resume_noirq) if (drv && drv->pm && drv->pm->resume_noirq)
error = drv->pm->resume_noirq(dev); error = drv->pm->resume_noirq(dev);
} else {
pci_pm_default_resume_noirq(pci_dev);
}
return error; return error;
} }
...@@ -633,14 +623,13 @@ static int pci_pm_freeze(struct device *dev) ...@@ -633,14 +623,13 @@ static int pci_pm_freeze(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_FREEZE); return pci_legacy_suspend(dev, PMSG_FREEZE);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->freeze) {
if (drv->pm->freeze) {
error = drv->pm->freeze(dev); error = drv->pm->freeze(dev);
suspend_report_result(drv->pm->freeze, error); suspend_report_result(drv->pm->freeze, error);
} }
} else {
if (!error)
pci_pm_default_suspend_generic(pci_dev); pci_pm_default_suspend_generic(pci_dev);
}
return error; return error;
} }
...@@ -654,14 +643,13 @@ static int pci_pm_freeze_noirq(struct device *dev) ...@@ -654,14 +643,13 @@ static int pci_pm_freeze_noirq(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend_late(dev, PMSG_FREEZE); return pci_legacy_suspend_late(dev, PMSG_FREEZE);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->freeze_noirq) {
if (drv->pm->freeze_noirq) {
error = drv->pm->freeze_noirq(dev); error = drv->pm->freeze_noirq(dev);
suspend_report_result(drv->pm->freeze_noirq, error); suspend_report_result(drv->pm->freeze_noirq, error);
} }
} else {
if (!error)
pci_pm_set_unknown_state(pci_dev); pci_pm_set_unknown_state(pci_dev);
}
return error; return error;
} }
...@@ -675,12 +663,10 @@ static int pci_pm_thaw(struct device *dev) ...@@ -675,12 +663,10 @@ static int pci_pm_thaw(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume(dev); return pci_legacy_resume(dev);
if (drv && drv->pm) {
if (drv->pm->thaw)
error = drv->pm->thaw(dev);
} else {
pci_pm_reenable_device(pci_dev); pci_pm_reenable_device(pci_dev);
}
if (drv && drv->pm && drv->pm->thaw)
error = drv->pm->thaw(dev);
return error; return error;
} }
...@@ -694,12 +680,10 @@ static int pci_pm_thaw_noirq(struct device *dev) ...@@ -694,12 +680,10 @@ static int pci_pm_thaw_noirq(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev); return pci_legacy_resume_early(dev);
if (drv && drv->pm) {
if (drv->pm->thaw_noirq)
error = drv->pm->thaw_noirq(dev);
} else {
pci_update_current_state(pci_dev, PCI_D0); pci_update_current_state(pci_dev, PCI_D0);
}
if (drv && drv->pm && drv->pm->thaw_noirq)
error = drv->pm->thaw_noirq(dev);
return error; return error;
} }
...@@ -713,16 +697,13 @@ static int pci_pm_poweroff(struct device *dev) ...@@ -713,16 +697,13 @@ static int pci_pm_poweroff(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_HIBERNATE); return pci_legacy_suspend(dev, PMSG_HIBERNATE);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->poweroff) {
if (drv->pm->poweroff) {
error = drv->pm->poweroff(dev); error = drv->pm->poweroff(dev);
suspend_report_result(drv->pm->poweroff, error); suspend_report_result(drv->pm->poweroff, error);
} }
} else {
pci_pm_default_suspend(pci_dev);
}
pci_fixup_device(pci_fixup_suspend, pci_dev); if (!error)
pci_pm_default_suspend(pci_dev);
return error; return error;
} }
...@@ -735,12 +716,10 @@ static int pci_pm_poweroff_noirq(struct device *dev) ...@@ -735,12 +716,10 @@ static int pci_pm_poweroff_noirq(struct device *dev)
if (pci_has_legacy_pm_support(to_pci_dev(dev))) if (pci_has_legacy_pm_support(to_pci_dev(dev)))
return pci_legacy_suspend_late(dev, PMSG_HIBERNATE); return pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
if (drv && drv->pm) { if (drv && drv->pm && drv->pm->poweroff_noirq) {
if (drv->pm->poweroff_noirq) {
error = drv->pm->poweroff_noirq(dev); error = drv->pm->poweroff_noirq(dev);
suspend_report_result(drv->pm->poweroff_noirq, error); suspend_report_result(drv->pm->poweroff_noirq, error);
} }
}
return error; return error;
} }
...@@ -754,14 +733,10 @@ static int pci_pm_restore(struct device *dev) ...@@ -754,14 +733,10 @@ static int pci_pm_restore(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume(dev); return pci_legacy_resume(dev);
if (drv && drv->pm) { error = pci_pm_default_resume(pci_dev);
pci_fixup_device(pci_fixup_resume, pci_dev);
if (drv->pm->restore) if (!error && drv && drv->pm && drv->pm->restore)
error = drv->pm->restore(dev); error = drv->pm->restore(dev);
} else {
error = pci_pm_default_resume(pci_dev);
}
return error; return error;
} }
...@@ -775,14 +750,10 @@ static int pci_pm_restore_noirq(struct device *dev) ...@@ -775,14 +750,10 @@ static int pci_pm_restore_noirq(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev); return pci_legacy_resume_early(dev);
if (drv && drv->pm) { pci_pm_default_resume_noirq(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (drv->pm->restore_noirq) if (drv && drv->pm && drv->pm->restore_noirq)
error = drv->pm->restore_noirq(dev); error = drv->pm->restore_noirq(dev);
} else {
pci_pm_default_resume_noirq(pci_dev);
}
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment