- Look at pm_message_t::state (along with the message event type) to
determine the PCI power state to return. This allows all of the PCI
power states to be used with this helper (and with the sysfs runtime
PM interface).
[ Previously, the returned value was limited to PCI_D0 or PCI_D3hot
depending on whether PM_EVENT_ON or PM_EVENT_{FREEZE,SUSPEND} were
specified. ]
- Print an error w/ device info when we get an invalid state; use
WARN_ON() instead of BUG(), so we don't needlessly crash a machine.
- Print state translation when debug is enabled.
Signed-off-by: Patrick Mochel <[email protected]>
---
drivers/pci/pci.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
applies-to: 7b4d08b2816a4aefc2b9891091e6a790526ea15e
8a658ba724d1f1e71fc951745e091aa1afa4ff6f
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d2d1879..2f160aa 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -404,30 +404,39 @@ int (*platform_pci_choose_state)(struct
* message.
*/
-pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
+pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t msg)
{
+ pci_power_t state = PCI_D3hot;
int ret;
if (!pci_find_capability(dev, PCI_CAP_ID_PM))
return PCI_D0;
if (platform_pci_choose_state) {
- ret = platform_pci_choose_state(dev, state);
+ ret = platform_pci_choose_state(dev, msg);
if (ret >= 0)
- state.event = ret;
+ msg.state = ret;
}
- switch (state.event) {
+ switch (msg.event) {
case PM_EVENT_ON:
- return PCI_D0;
+ state = PCI_D0;
+ break;
case PM_EVENT_FREEZE:
case PM_EVENT_SUSPEND:
- return PCI_D3hot;
+ if (msg.state && msg.state <= PCI_D3hot)
+ state = msg.state;
+ break;
default:
- printk("They asked me for state %d\n", state.event);
- BUG();
- }
- return PCI_D0;
+ dev_err(&dev->dev, "PCI: Invalid PM Event [Event %d] [State %u]\n",
+ msg.event, msg.state);
+ WARN_ON(1);
+ state = PCI_D0;
+ break;
+ }
+ dev_dbg(&dev->dev, "PCI: Translated Power Message %d/%u -> %u\n",
+ msg.event, msg.state, state);
+ return state;
}
EXPORT_SYMBOL(pci_choose_state);
---
0.99.9.GIT
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]