aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/pci-driver.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ab1d615425a8..6613bef25bf2 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -445,11 +445,11 @@ static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
445 pci_save_state(pci_dev); 445 pci_save_state(pci_dev);
446} 446}
447 447
448static void pci_pm_default_suspend(struct pci_dev *pci_dev) 448static void pci_pm_default_suspend(struct pci_dev *pci_dev, bool prepare)
449{ 449{
450 pci_pm_default_suspend_generic(pci_dev); 450 pci_pm_default_suspend_generic(pci_dev);
451 451
452 if (!pci_is_bridge(pci_dev)) 452 if (prepare && !pci_is_bridge(pci_dev))
453 pci_prepare_to_sleep(pci_dev); 453 pci_prepare_to_sleep(pci_dev);
454 454
455 pci_fixup_device(pci_fixup_suspend, pci_dev); 455 pci_fixup_device(pci_fixup_suspend, pci_dev);
@@ -497,19 +497,19 @@ static void pci_pm_complete(struct device *dev)
497static int pci_pm_suspend(struct device *dev) 497static int pci_pm_suspend(struct device *dev)
498{ 498{
499 struct pci_dev *pci_dev = to_pci_dev(dev); 499 struct pci_dev *pci_dev = to_pci_dev(dev);
500 struct device_driver *drv = dev->driver; 500 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
501 int error = 0; 501 int error = 0;
502 502
503 if (pci_has_legacy_pm_support(pci_dev)) 503 if (pci_has_legacy_pm_support(pci_dev))
504 return pci_legacy_suspend(dev, PMSG_SUSPEND); 504 return pci_legacy_suspend(dev, PMSG_SUSPEND);
505 505
506 if (drv && drv->pm && drv->pm->suspend) { 506 if (pm && pm->suspend) {
507 error = drv->pm->suspend(dev); 507 error = pm->suspend(dev);
508 suspend_report_result(drv->pm->suspend, error); 508 suspend_report_result(pm->suspend, error);
509 } 509 }
510 510
511 if (!error) 511 if (!error)
512 pci_pm_default_suspend(pci_dev); 512 pci_pm_default_suspend(pci_dev, !!pm);
513 513
514 return error; 514 return error;
515} 515}
@@ -663,22 +663,19 @@ static int pci_pm_thaw(struct device *dev)
663static int pci_pm_poweroff(struct device *dev) 663static int pci_pm_poweroff(struct device *dev)
664{ 664{
665 struct pci_dev *pci_dev = to_pci_dev(dev); 665 struct pci_dev *pci_dev = to_pci_dev(dev);
666 struct device_driver *drv = dev->driver; 666 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
667 int error = 0; 667 int error = 0;
668 668
669 if (pci_has_legacy_pm_support(pci_dev)) 669 if (pci_has_legacy_pm_support(pci_dev))
670 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 670 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
671 671
672 if (!drv || !drv->pm) 672 if (pm && pm->poweroff) {
673 return 0; 673 error = pm->poweroff(dev);
674 674 suspend_report_result(pm->poweroff, error);
675 if (drv->pm->poweroff) {
676 error = drv->pm->poweroff(dev);
677 suspend_report_result(drv->pm->poweroff, error);
678 } 675 }
679 676
680 if (!error) 677 if (!error)
681 pci_pm_default_suspend(pci_dev); 678 pci_pm_default_suspend(pci_dev, !!pm);
682 679
683 return error; 680 return error;
684} 681}