diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-10-06 16:46:05 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 13:44:29 -0500 |
commit | adf094931ffb25ef4b381559918f1a34181a5273 (patch) | |
tree | bd343d4c15b21dff6a73359fd2d82ff77e30e0d4 /drivers/pci/pci-driver.c | |
parent | 238c6d54830c624f34ac9cf123ac04aebfca5013 (diff) |
PM: Simplify the new suspend/hibernation framework for devices
PM: Simplify the new suspend/hibernation framework for devices
Following the discussion at the Kernel Summit, simplify the new
device PM framework by merging 'struct pm_ops' and
'struct pm_ext_ops' and removing pointers to 'struct pm_ext_ops'
from 'struct platform_driver' and 'struct pci_driver'.
After this change, the suspend/hibernation callbacks will only
reside in 'struct device_driver' as well as at the bus type/
device class/device type level. Accordingly, PCI and platform
device drivers are now expected to put their suspend/hibernation
callbacks into the 'struct device_driver' embedded in
'struct pci_driver' or 'struct platform_driver', respectively.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r-- | drivers/pci/pci-driver.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index b4cdd690ae71..4042d211c3e5 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -433,8 +433,7 @@ static int pci_pm_suspend(struct device *dev) | |||
433 | 433 | ||
434 | static int pci_pm_suspend_noirq(struct device *dev) | 434 | static int pci_pm_suspend_noirq(struct device *dev) |
435 | { | 435 | { |
436 | struct pci_dev *pci_dev = to_pci_dev(dev); | 436 | struct device_driver *drv = dev->driver; |
437 | struct pci_driver *drv = pci_dev->driver; | ||
438 | int error = 0; | 437 | int error = 0; |
439 | 438 | ||
440 | if (drv && drv->pm) { | 439 | if (drv && drv->pm) { |
@@ -469,11 +468,10 @@ static int pci_pm_resume(struct device *dev) | |||
469 | 468 | ||
470 | static int pci_pm_resume_noirq(struct device *dev) | 469 | static int pci_pm_resume_noirq(struct device *dev) |
471 | { | 470 | { |
472 | struct pci_dev *pci_dev = to_pci_dev(dev); | 471 | struct device_driver *drv = dev->driver; |
473 | struct pci_driver *drv = pci_dev->driver; | ||
474 | int error = 0; | 472 | int error = 0; |
475 | 473 | ||
476 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | 474 | pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); |
477 | 475 | ||
478 | if (drv && drv->pm) { | 476 | if (drv && drv->pm) { |
479 | if (drv->pm->resume_noirq) | 477 | if (drv->pm->resume_noirq) |
@@ -519,8 +517,7 @@ static int pci_pm_freeze(struct device *dev) | |||
519 | 517 | ||
520 | static int pci_pm_freeze_noirq(struct device *dev) | 518 | static int pci_pm_freeze_noirq(struct device *dev) |
521 | { | 519 | { |
522 | struct pci_dev *pci_dev = to_pci_dev(dev); | 520 | struct device_driver *drv = dev->driver; |
523 | struct pci_driver *drv = pci_dev->driver; | ||
524 | int error = 0; | 521 | int error = 0; |
525 | 522 | ||
526 | if (drv && drv->pm) { | 523 | if (drv && drv->pm) { |
@@ -553,15 +550,14 @@ static int pci_pm_thaw(struct device *dev) | |||
553 | 550 | ||
554 | static int pci_pm_thaw_noirq(struct device *dev) | 551 | static int pci_pm_thaw_noirq(struct device *dev) |
555 | { | 552 | { |
556 | struct pci_dev *pci_dev = to_pci_dev(dev); | 553 | struct device_driver *drv = dev->driver; |
557 | struct pci_driver *drv = pci_dev->driver; | ||
558 | int error = 0; | 554 | int error = 0; |
559 | 555 | ||
560 | if (drv && drv->pm) { | 556 | if (drv && drv->pm) { |
561 | if (drv->pm->thaw_noirq) | 557 | if (drv->pm->thaw_noirq) |
562 | error = drv->pm->thaw_noirq(dev); | 558 | error = drv->pm->thaw_noirq(dev); |
563 | } else { | 559 | } else { |
564 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | 560 | pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); |
565 | error = pci_legacy_resume_early(dev); | 561 | error = pci_legacy_resume_early(dev); |
566 | } | 562 | } |
567 | 563 | ||
@@ -589,8 +585,7 @@ static int pci_pm_poweroff(struct device *dev) | |||
589 | 585 | ||
590 | static int pci_pm_poweroff_noirq(struct device *dev) | 586 | static int pci_pm_poweroff_noirq(struct device *dev) |
591 | { | 587 | { |
592 | struct pci_dev *pci_dev = to_pci_dev(dev); | 588 | struct device_driver *drv = dev->driver; |
593 | struct pci_driver *drv = pci_dev->driver; | ||
594 | int error = 0; | 589 | int error = 0; |
595 | 590 | ||
596 | if (drv && drv->pm) { | 591 | if (drv && drv->pm) { |
@@ -625,7 +620,7 @@ static int pci_pm_restore(struct device *dev) | |||
625 | static int pci_pm_restore_noirq(struct device *dev) | 620 | static int pci_pm_restore_noirq(struct device *dev) |
626 | { | 621 | { |
627 | struct pci_dev *pci_dev = to_pci_dev(dev); | 622 | struct pci_dev *pci_dev = to_pci_dev(dev); |
628 | struct pci_driver *drv = pci_dev->driver; | 623 | struct device_driver *drv = dev->driver; |
629 | int error = 0; | 624 | int error = 0; |
630 | 625 | ||
631 | pci_fixup_device(pci_fixup_resume, pci_dev); | 626 | pci_fixup_device(pci_fixup_resume, pci_dev); |
@@ -654,17 +649,15 @@ static int pci_pm_restore_noirq(struct device *dev) | |||
654 | 649 | ||
655 | #endif /* !CONFIG_HIBERNATION */ | 650 | #endif /* !CONFIG_HIBERNATION */ |
656 | 651 | ||
657 | struct pm_ext_ops pci_pm_ops = { | 652 | struct dev_pm_ops pci_dev_pm_ops = { |
658 | .base = { | 653 | .prepare = pci_pm_prepare, |
659 | .prepare = pci_pm_prepare, | 654 | .complete = pci_pm_complete, |
660 | .complete = pci_pm_complete, | 655 | .suspend = pci_pm_suspend, |
661 | .suspend = pci_pm_suspend, | 656 | .resume = pci_pm_resume, |
662 | .resume = pci_pm_resume, | 657 | .freeze = pci_pm_freeze, |
663 | .freeze = pci_pm_freeze, | 658 | .thaw = pci_pm_thaw, |
664 | .thaw = pci_pm_thaw, | 659 | .poweroff = pci_pm_poweroff, |
665 | .poweroff = pci_pm_poweroff, | 660 | .restore = pci_pm_restore, |
666 | .restore = pci_pm_restore, | ||
667 | }, | ||
668 | .suspend_noirq = pci_pm_suspend_noirq, | 661 | .suspend_noirq = pci_pm_suspend_noirq, |
669 | .resume_noirq = pci_pm_resume_noirq, | 662 | .resume_noirq = pci_pm_resume_noirq, |
670 | .freeze_noirq = pci_pm_freeze_noirq, | 663 | .freeze_noirq = pci_pm_freeze_noirq, |
@@ -673,7 +666,7 @@ struct pm_ext_ops pci_pm_ops = { | |||
673 | .restore_noirq = pci_pm_restore_noirq, | 666 | .restore_noirq = pci_pm_restore_noirq, |
674 | }; | 667 | }; |
675 | 668 | ||
676 | #define PCI_PM_OPS_PTR &pci_pm_ops | 669 | #define PCI_PM_OPS_PTR (&pci_dev_pm_ops) |
677 | 670 | ||
678 | #else /* !CONFIG_PM_SLEEP */ | 671 | #else /* !CONFIG_PM_SLEEP */ |
679 | 672 | ||
@@ -703,9 +696,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner, | |||
703 | drv->driver.owner = owner; | 696 | drv->driver.owner = owner; |
704 | drv->driver.mod_name = mod_name; | 697 | drv->driver.mod_name = mod_name; |
705 | 698 | ||
706 | if (drv->pm) | ||
707 | drv->driver.pm = &drv->pm->base; | ||
708 | |||
709 | spin_lock_init(&drv->dynids.lock); | 699 | spin_lock_init(&drv->dynids.lock); |
710 | INIT_LIST_HEAD(&drv->dynids.list); | 700 | INIT_LIST_HEAD(&drv->dynids.list); |
711 | 701 | ||