diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2009-02-03 19:59:09 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-02-04 20:21:08 -0500 |
commit | 99dadce8756bf08f5f8baf749533d044f6b3ff25 (patch) | |
tree | 7593c043681c463382fafb22737e4f4a7f52f00b /drivers/pci | |
parent | 144a76bc885ef4852601c66595326e59f12877f8 (diff) |
PCI PM: Fix saving of device state in pci_legacy_suspend
Make pci_legacy_suspend() save the state of the device if it is
in PCI_UNKNOWN after its suspend callback has run and warn only if
the power state of the device has been changed by its suspend
callback.
Also, use WARN_ONCE(), which is more useful, in pci_legacy_suspend(),
so that the name of the offending function is printed.
Additionally, remove the unnecessary line of code setting
pci_dev->state_saved.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/pci-driver.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 6613bef25bf2..fdb6a697e05a 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -355,6 +355,8 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state) | |||
355 | int i = 0; | 355 | int i = 0; |
356 | 356 | ||
357 | if (drv && drv->suspend) { | 357 | if (drv && drv->suspend) { |
358 | pci_power_t prev = pci_dev->current_state; | ||
359 | |||
358 | pci_dev->state_saved = false; | 360 | pci_dev->state_saved = false; |
359 | 361 | ||
360 | i = drv->suspend(pci_dev, state); | 362 | i = drv->suspend(pci_dev, state); |
@@ -365,12 +367,16 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state) | |||
365 | if (pci_dev->state_saved) | 367 | if (pci_dev->state_saved) |
366 | goto Fixup; | 368 | goto Fixup; |
367 | 369 | ||
368 | if (WARN_ON_ONCE(pci_dev->current_state != PCI_D0)) | 370 | if (pci_dev->current_state != PCI_D0 |
371 | && pci_dev->current_state != PCI_UNKNOWN) { | ||
372 | WARN_ONCE(pci_dev->current_state != prev, | ||
373 | "PCI PM: Device state not saved by %pF\n", | ||
374 | drv->suspend); | ||
369 | goto Fixup; | 375 | goto Fixup; |
376 | } | ||
370 | } | 377 | } |
371 | 378 | ||
372 | pci_save_state(pci_dev); | 379 | pci_save_state(pci_dev); |
373 | pci_dev->state_saved = true; | ||
374 | /* | 380 | /* |
375 | * This is for compatibility with existing code with legacy PM support. | 381 | * This is for compatibility with existing code with legacy PM support. |
376 | */ | 382 | */ |