From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
Pavel Machek <pavel@suse.cz>,
pm list <linux-pm@lists.linux-foundation.org>,
Matthew Wilcox <matthew@wil.cx>, "H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>, Greg KH <greg@kroah.com>,
Linux PCI <linux-pci@vger.kernel.org>
Subject: [RFC][PATCH 6/10] PCI PM: Rearrange code in pci-driver.c
Date: Tue, 30 Dec 2008 23:43:06 +0100 [thread overview]
Message-ID: <200812302343.07164.rjw@sisk.pl> (raw)
In-Reply-To: <200812302333.45560.rjw@sisk.pl>
Rename two functions and rearrange code in drivers/pci/pci-driver.c
so that it's easier to follow. In particular, separate invocations
of the legacy callbacks from the rest of the new callbacks' code.
No functional changes should result from this.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/pci/pci-driver.c | 104 +++++++++++++++++++++++++++++------------------
1 file changed, 65 insertions(+), 39 deletions(-)
Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -304,7 +304,7 @@ static void pci_device_shutdown(struct d
* Default "suspend" method for devices that have no driver provided suspend,
* or not even a driver at all (second part).
*/
-static void pci_default_pm_suspend_late(struct pci_dev *pci_dev)
+static void pci_pm_set_unknown_state(struct pci_dev *pci_dev)
{
/*
* mark its power state as "unknown", since we don't know if
@@ -318,7 +318,7 @@ static void pci_default_pm_suspend_late(
* Default "resume" method for devices that have no driver provided resume,
* or not even a driver at all (second part).
*/
-static int pci_default_pm_resume_late(struct pci_dev *pci_dev)
+static int pci_pm_reenable_device(struct pci_dev *pci_dev)
{
int retval;
@@ -349,7 +349,7 @@ static int pci_legacy_suspend(struct dev
* This is for compatibility with existing code with legacy PM
* support.
*/
- pci_default_pm_suspend_late(pci_dev);
+ pci_pm_set_unknown_state(pci_dev);
}
return i;
}
@@ -378,7 +378,7 @@ static int pci_legacy_resume(struct devi
} else {
/* restore the PCI config space */
pci_restore_state(pci_dev);
- error = pci_default_pm_resume_late(pci_dev);
+ error = pci_pm_reenable_device(pci_dev);
}
return error;
}
@@ -445,7 +445,7 @@ static int pci_pm_default_resume(struct
if (!pci_is_bridge(pci_dev))
pci_enable_wake(pci_dev, PCI_D0, false);
- return pci_default_pm_resume_late(pci_dev);
+ return pci_pm_reenable_device(pci_dev);
}
static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
@@ -504,17 +504,21 @@ static int pci_pm_suspend(struct device
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ error = pci_legacy_suspend(dev, PMSG_SUSPEND);
+ goto Exit;
+ }
+
if (drv && drv->pm) {
if (drv->pm->suspend) {
error = drv->pm->suspend(dev);
suspend_report_result(drv->pm->suspend, error);
}
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- error = pci_legacy_suspend(dev, PMSG_SUSPEND);
} else {
pci_pm_default_suspend(pci_dev);
}
+ Exit:
pci_fixup_device(pci_fixup_suspend, pci_dev);
return error;
@@ -526,15 +530,16 @@ static int pci_pm_suspend_noirq(struct d
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev))
+ return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
+
if (drv && drv->pm) {
if (drv->pm->suspend_noirq) {
error = drv->pm->suspend_noirq(dev);
suspend_report_result(drv->pm->suspend_noirq, error);
}
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- error = pci_legacy_suspend_late(dev, PMSG_SUSPEND);
} else {
- pci_default_pm_suspend_late(pci_dev);
+ pci_pm_set_unknown_state(pci_dev);
}
return error;
@@ -546,14 +551,16 @@ static int pci_pm_resume(struct device *
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume, pci_dev);
+ return pci_legacy_resume(dev);
+ }
+
if (drv && drv->pm) {
pci_fixup_device(pci_fixup_resume, pci_dev);
if (drv->pm->resume)
error = drv->pm->resume(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume, pci_dev);
- error = pci_legacy_resume(dev);
} else {
error = pci_pm_default_resume(pci_dev);
}
@@ -567,14 +574,16 @@ static int pci_pm_resume_noirq(struct de
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume_early, pci_dev);
+ return pci_legacy_resume_early(dev);
+ }
+
if (drv && drv->pm) {
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (drv->pm->resume_noirq)
error = drv->pm->resume_noirq(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume_early, pci_dev);
- error = pci_legacy_resume_early(dev);
} else {
pci_pm_default_resume_noirq(pci_dev);
}
@@ -599,14 +608,17 @@ static int pci_pm_freeze(struct device *
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ error = pci_legacy_suspend(dev, PMSG_FREEZE);
+ pci_fixup_device(pci_fixup_suspend, pci_dev);
+ return error;
+ }
+
if (drv && drv->pm) {
if (drv->pm->freeze) {
error = drv->pm->freeze(dev);
suspend_report_result(drv->pm->freeze, error);
}
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- error = pci_legacy_suspend(dev, PMSG_FREEZE);
- pci_fixup_device(pci_fixup_suspend, pci_dev);
} else {
pci_pm_default_suspend_generic(pci_dev);
}
@@ -620,15 +632,16 @@ static int pci_pm_freeze_noirq(struct de
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev))
+ return pci_legacy_suspend_late(dev, PMSG_FREEZE);
+
if (drv && drv->pm) {
if (drv->pm->freeze_noirq) {
error = drv->pm->freeze_noirq(dev);
suspend_report_result(drv->pm->freeze_noirq, error);
}
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- error = pci_legacy_suspend_late(dev, PMSG_FREEZE);
} else {
- pci_default_pm_suspend_late(pci_dev);
+ pci_pm_set_unknown_state(pci_dev);
}
return error;
@@ -640,14 +653,16 @@ static int pci_pm_thaw(struct device *de
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume, pci_dev);
+ return pci_legacy_resume(dev);
+ }
+
if (drv && drv->pm) {
if (drv->pm->thaw)
error = drv->pm->thaw(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume, pci_dev);
- error = pci_legacy_resume(dev);
} else {
- pci_default_pm_resume_late(pci_dev);
+ pci_pm_reenable_device(pci_dev);
}
return error;
@@ -659,12 +674,14 @@ static int pci_pm_thaw_noirq(struct devi
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev));
+ return pci_legacy_resume_early(dev);
+ }
+
if (drv && drv->pm) {
if (drv->pm->thaw_noirq)
error = drv->pm->thaw_noirq(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev));
- error = pci_legacy_resume_early(dev);
} else {
pci_update_current_state(pci_dev, PCI_D0);
}
@@ -678,17 +695,21 @@ static int pci_pm_poweroff(struct device
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ error = pci_legacy_suspend(dev, PMSG_HIBERNATE);
+ goto Exit;
+ }
+
if (drv && drv->pm) {
if (drv->pm->poweroff) {
error = drv->pm->poweroff(dev);
suspend_report_result(drv->pm->poweroff, error);
}
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- error = pci_legacy_suspend(dev, PMSG_HIBERNATE);
} else {
pci_pm_default_suspend(pci_dev);
}
+ Exit:
pci_fixup_device(pci_fixup_suspend, pci_dev);
return error;
@@ -699,13 +720,14 @@ static int pci_pm_poweroff_noirq(struct
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(to_pci_dev(dev)))
+ return pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
+
if (drv && drv->pm) {
if (drv->pm->poweroff_noirq) {
error = drv->pm->poweroff_noirq(dev);
suspend_report_result(drv->pm->poweroff_noirq, error);
}
- } else if (pci_has_legacy_pm_support(to_pci_dev(dev))) {
- error = pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
}
return error;
@@ -717,14 +739,16 @@ static int pci_pm_restore(struct device
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume, pci_dev);
+ return pci_legacy_resume(dev);
+ }
+
if (drv && drv->pm) {
pci_fixup_device(pci_fixup_resume, pci_dev);
if (drv->pm->restore)
error = drv->pm->restore(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume, pci_dev);
- error = pci_legacy_resume(dev);
} else {
error = pci_pm_default_resume(pci_dev);
}
@@ -738,14 +762,16 @@ static int pci_pm_restore_noirq(struct d
struct device_driver *drv = dev->driver;
int error = 0;
+ if (pci_has_legacy_pm_support(pci_dev)) {
+ pci_fixup_device(pci_fixup_resume_early, pci_dev);
+ return pci_legacy_resume_early(dev);
+ }
+
if (drv && drv->pm) {
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (drv->pm->restore_noirq)
error = drv->pm->restore_noirq(dev);
- } else if (pci_has_legacy_pm_support(pci_dev)) {
- pci_fixup_device(pci_fixup_resume_early, pci_dev);
- error = pci_legacy_resume_early(dev);
} else {
pci_pm_default_resume_noirq(pci_dev);
}
next prev parent reply other threads:[~2008-12-30 22:51 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200812190049.34343.rjw@sisk.pl>
2008-12-28 15:07 ` [RFC][PATCH] PCI PM: Make new suspend-resume callbacks carry out core operations (rev. 2) Rafael J. Wysocki
2008-12-30 22:33 ` [RFC][PATCH 0/10] PCI PM: Make new suspend-resume callbacks carry out core operations Rafael J. Wysocki
2008-12-30 22:35 ` [RFC][PATCH 1/10] PCI PM: Fix poweroff and restore callbacks Rafael J. Wysocki
2009-01-05 10:00 ` Pavel Machek
2008-12-30 22:37 ` [RFC][PATCH 2/10] PCI PM: Add suspend counterpart of pci_reenable_device Rafael J. Wysocki
2009-01-05 10:49 ` Pavel Machek
2009-01-05 13:17 ` Rafael J. Wysocki
2008-12-30 22:38 ` [RFC][PATCH 3/10] PCI PM: Power-manage devices without drivers during suspend-resume Rafael J. Wysocki
2009-01-05 10:51 ` Pavel Machek
2008-12-30 22:40 ` [RFC][PATCH 4/10] PCI PM: Move pci_has_legacy_pm_support Rafael J. Wysocki
2009-01-05 10:51 ` Pavel Machek
2008-12-30 22:41 ` [RFC][PATCH 5/10] PCI PM: Avoid touching devices behind bridges in unknown state Rafael J. Wysocki
2009-01-01 21:09 ` [RFC][PATCH 5/10] PCI PM: Avoid touching devices behind bridges in unknown state (rev. 2) Rafael J. Wysocki
2009-01-05 10:58 ` Pavel Machek
2009-01-05 13:30 ` Rafael J. Wysocki
2009-01-07 22:32 ` Pavel Machek
2009-01-07 23:02 ` Rafael J. Wysocki
2008-12-30 22:43 ` Rafael J. Wysocki [this message]
2009-01-05 11:25 ` [RFC][PATCH 6/10] PCI PM: Rearrange code in pci-driver.c Pavel Machek
2009-01-05 13:32 ` Rafael J. Wysocki
2008-12-30 22:44 ` [RFC][PATCH 7/10] PCI PM: Call pci_fixup_device from legacy routines Rafael J. Wysocki
2009-01-05 11:25 ` Pavel Machek
2008-12-30 22:45 ` [RFC][PATCH 8/10] PCI PM: Register power state of devices during initialization Rafael J. Wysocki
2009-01-05 11:19 ` Pavel Machek
2008-12-30 22:47 ` [RFC][PATCH 9/10] PCI PM: Run default PM callbacks for all devices using new framework Rafael J. Wysocki
2009-01-05 11:26 ` Pavel Machek
2008-12-30 22:49 ` [RFC][PATCH 10/10] PCI PM: Put PM callbacks in the order of execution Rafael J. Wysocki
2009-01-05 11:21 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200812302343.07164.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=greg@kroah.com \
--cc=hpa@zytor.com \
--cc=jbarnes@virtuousgeek.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=matthew@wil.cx \
--cc=pavel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®