aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-01-07 07:11:28 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 14:19:39 -0500
commitd67e37d7933ba3b28a63ff38c957e433aaca5dc4 (patch)
tree5cb865b181891308695be0074f057756bd7172c9 /drivers/pci
parent98e6e286d7b01deb7453b717aa38ebb69d6cefc0 (diff)
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: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c135
1 files changed, 53 insertions, 82 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 02bf4d4125e4..b7e67c2f40b9 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -486,6 +486,8 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev)
486 486
487 if (!pci_is_bridge(pci_dev)) 487 if (!pci_is_bridge(pci_dev))
488 pci_prepare_to_sleep(pci_dev); 488 pci_prepare_to_sleep(pci_dev);
489
490 pci_fixup_device(pci_fixup_suspend, pci_dev);
489} 491}
490 492
491static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) 493static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
@@ -536,16 +538,13 @@ static int pci_pm_suspend(struct device *dev)
536 if (pci_has_legacy_pm_support(pci_dev)) 538 if (pci_has_legacy_pm_support(pci_dev))
537 return pci_legacy_suspend(dev, PMSG_SUSPEND); 539 return pci_legacy_suspend(dev, PMSG_SUSPEND);
538 540
539 if (drv && drv->pm) { 541 if (drv && drv->pm && drv->pm->suspend) {
540 if (drv->pm->suspend) { 542 error = drv->pm->suspend(dev);
541 error = drv->pm->suspend(dev); 543 suspend_report_result(drv->pm->suspend, error);
542 suspend_report_result(drv->pm->suspend, error);
543 }
544 } else {
545 pci_pm_default_suspend(pci_dev);
546 } 544 }
547 545
548 pci_fixup_device(pci_fixup_suspend, pci_dev); 546 if (!error)
547 pci_pm_default_suspend(pci_dev);
549 548
550 return error; 549 return error;
551} 550}
@@ -559,15 +558,14 @@ static int pci_pm_suspend_noirq(struct device *dev)
559 if (pci_has_legacy_pm_support(pci_dev)) 558 if (pci_has_legacy_pm_support(pci_dev))
560 return pci_legacy_suspend_late(dev, PMSG_SUSPEND); 559 return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
561 560
562 if (drv && drv->pm) { 561 if (drv && drv->pm && drv->pm->suspend_noirq) {
563 if (drv->pm->suspend_noirq) { 562 error = drv->pm->suspend_noirq(dev);
564 error = drv->pm->suspend_noirq(dev); 563 suspend_report_result(drv->pm->suspend_noirq, error);
565 suspend_report_result(drv->pm->suspend_noirq, error);
566 }
567 } else {
568 pci_pm_set_unknown_state(pci_dev);
569 } 564 }
570 565
566 if (!error)
567 pci_pm_set_unknown_state(pci_dev);
568
571 return error; 569 return error;
572} 570}
573 571
@@ -580,14 +578,10 @@ static int pci_pm_resume(struct device *dev)
580 if (pci_has_legacy_pm_support(pci_dev)) 578 if (pci_has_legacy_pm_support(pci_dev))
581 return pci_legacy_resume(dev); 579 return pci_legacy_resume(dev);
582 580
583 if (drv && drv->pm) { 581 error = pci_pm_default_resume(pci_dev);
584 pci_fixup_device(pci_fixup_resume, pci_dev);
585 582
586 if (drv->pm->resume) 583 if (!error && drv && drv->pm && drv->pm->resume)
587 error = drv->pm->resume(dev); 584 error = drv->pm->resume(dev);
588 } else {
589 error = pci_pm_default_resume(pci_dev);
590 }
591 585
592 return error; 586 return error;
593} 587}
@@ -601,14 +595,10 @@ static int pci_pm_resume_noirq(struct device *dev)
601 if (pci_has_legacy_pm_support(pci_dev)) 595 if (pci_has_legacy_pm_support(pci_dev))
602 return pci_legacy_resume_early(dev); 596 return pci_legacy_resume_early(dev);
603 597
604 if (drv && drv->pm) { 598 pci_pm_default_resume_noirq(pci_dev);
605 pci_fixup_device(pci_fixup_resume_early, pci_dev);
606 599
607 if (drv->pm->resume_noirq) 600 if (drv && drv->pm && drv->pm->resume_noirq)
608 error = drv->pm->resume_noirq(dev); 601 error = drv->pm->resume_noirq(dev);
609 } else {
610 pci_pm_default_resume_noirq(pci_dev);
611 }
612 602
613 return error; 603 return error;
614} 604}
@@ -633,15 +623,14 @@ static int pci_pm_freeze(struct device *dev)
633 if (pci_has_legacy_pm_support(pci_dev)) 623 if (pci_has_legacy_pm_support(pci_dev))
634 return pci_legacy_suspend(dev, PMSG_FREEZE); 624 return pci_legacy_suspend(dev, PMSG_FREEZE);
635 625
636 if (drv && drv->pm) { 626 if (drv && drv->pm && drv->pm->freeze) {
637 if (drv->pm->freeze) { 627 error = drv->pm->freeze(dev);
638 error = drv->pm->freeze(dev); 628 suspend_report_result(drv->pm->freeze, error);
639 suspend_report_result(drv->pm->freeze, error);
640 }
641 } else {
642 pci_pm_default_suspend_generic(pci_dev);
643 } 629 }
644 630
631 if (!error)
632 pci_pm_default_suspend_generic(pci_dev);
633
645 return error; 634 return error;
646} 635}
647 636
@@ -654,15 +643,14 @@ static int pci_pm_freeze_noirq(struct device *dev)
654 if (pci_has_legacy_pm_support(pci_dev)) 643 if (pci_has_legacy_pm_support(pci_dev))
655 return pci_legacy_suspend_late(dev, PMSG_FREEZE); 644 return pci_legacy_suspend_late(dev, PMSG_FREEZE);
656 645
657 if (drv && drv->pm) { 646 if (drv && drv->pm && drv->pm->freeze_noirq) {
658 if (drv->pm->freeze_noirq) { 647 error = drv->pm->freeze_noirq(dev);
659 error = drv->pm->freeze_noirq(dev); 648 suspend_report_result(drv->pm->freeze_noirq, error);
660 suspend_report_result(drv->pm->freeze_noirq, error);
661 }
662 } else {
663 pci_pm_set_unknown_state(pci_dev);
664 } 649 }
665 650
651 if (!error)
652 pci_pm_set_unknown_state(pci_dev);
653
666 return error; 654 return error;
667} 655}
668 656
@@ -675,12 +663,10 @@ static int pci_pm_thaw(struct device *dev)
675 if (pci_has_legacy_pm_support(pci_dev)) 663 if (pci_has_legacy_pm_support(pci_dev))
676 return pci_legacy_resume(dev); 664 return pci_legacy_resume(dev);
677 665
678 if (drv && drv->pm) { 666 pci_pm_reenable_device(pci_dev);
679 if (drv->pm->thaw) 667
680 error = drv->pm->thaw(dev); 668 if (drv && drv->pm && drv->pm->thaw)
681 } else { 669 error = drv->pm->thaw(dev);
682 pci_pm_reenable_device(pci_dev);
683 }
684 670
685 return error; 671 return error;
686} 672}
@@ -694,12 +680,10 @@ static int pci_pm_thaw_noirq(struct device *dev)
694 if (pci_has_legacy_pm_support(pci_dev)) 680 if (pci_has_legacy_pm_support(pci_dev))
695 return pci_legacy_resume_early(dev); 681 return pci_legacy_resume_early(dev);
696 682
697 if (drv && drv->pm) { 683 pci_update_current_state(pci_dev, PCI_D0);
698 if (drv->pm->thaw_noirq) 684
699 error = drv->pm->thaw_noirq(dev); 685 if (drv && drv->pm && drv->pm->thaw_noirq)
700 } else { 686 error = drv->pm->thaw_noirq(dev);
701 pci_update_current_state(pci_dev, PCI_D0);
702 }
703 687
704 return error; 688 return error;
705} 689}
@@ -713,16 +697,13 @@ static int pci_pm_poweroff(struct device *dev)
713 if (pci_has_legacy_pm_support(pci_dev)) 697 if (pci_has_legacy_pm_support(pci_dev))
714 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 698 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
715 699
716 if (drv && drv->pm) { 700 if (drv && drv->pm && drv->pm->poweroff) {
717 if (drv->pm->poweroff) { 701 error = drv->pm->poweroff(dev);
718 error = drv->pm->poweroff(dev); 702 suspend_report_result(drv->pm->poweroff, error);
719 suspend_report_result(drv->pm->poweroff, error);
720 }
721 } else {
722 pci_pm_default_suspend(pci_dev);
723 } 703 }
724 704
725 pci_fixup_device(pci_fixup_suspend, pci_dev); 705 if (!error)
706 pci_pm_default_suspend(pci_dev);
726 707
727 return error; 708 return error;
728} 709}
@@ -735,11 +716,9 @@ static int pci_pm_poweroff_noirq(struct device *dev)
735 if (pci_has_legacy_pm_support(to_pci_dev(dev))) 716 if (pci_has_legacy_pm_support(to_pci_dev(dev)))
736 return pci_legacy_suspend_late(dev, PMSG_HIBERNATE); 717 return pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
737 718
738 if (drv && drv->pm) { 719 if (drv && drv->pm && drv->pm->poweroff_noirq) {
739 if (drv->pm->poweroff_noirq) { 720 error = drv->pm->poweroff_noirq(dev);
740 error = drv->pm->poweroff_noirq(dev); 721 suspend_report_result(drv->pm->poweroff_noirq, error);
741 suspend_report_result(drv->pm->poweroff_noirq, error);
742 }
743 } 722 }
744 723
745 return error; 724 return error;
@@ -754,14 +733,10 @@ static int pci_pm_restore(struct device *dev)
754 if (pci_has_legacy_pm_support(pci_dev)) 733 if (pci_has_legacy_pm_support(pci_dev))
755 return pci_legacy_resume(dev); 734 return pci_legacy_resume(dev);
756 735
757 if (drv && drv->pm) { 736 error = pci_pm_default_resume(pci_dev);
758 pci_fixup_device(pci_fixup_resume, pci_dev);
759 737
760 if (drv->pm->restore) 738 if (!error && drv && drv->pm && drv->pm->restore)
761 error = drv->pm->restore(dev); 739 error = drv->pm->restore(dev);
762 } else {
763 error = pci_pm_default_resume(pci_dev);
764 }
765 740
766 return error; 741 return error;
767} 742}
@@ -775,14 +750,10 @@ static int pci_pm_restore_noirq(struct device *dev)
775 if (pci_has_legacy_pm_support(pci_dev)) 750 if (pci_has_legacy_pm_support(pci_dev))
776 return pci_legacy_resume_early(dev); 751 return pci_legacy_resume_early(dev);
777 752
778 if (drv && drv->pm) { 753 pci_pm_default_resume_noirq(pci_dev);
779 pci_fixup_device(pci_fixup_resume_early, pci_dev);
780 754
781 if (drv->pm->restore_noirq) 755 if (drv && drv->pm && drv->pm->restore_noirq)
782 error = drv->pm->restore_noirq(dev); 756 error = drv->pm->restore_noirq(dev);
783 } else {
784 pci_pm_default_resume_noirq(pci_dev);
785 }
786 757
787 return error; 758 return error;
788} 759}