diff options
author | Magnus Damm <damm@igel.co.jp> | 2009-08-20 14:25:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2009-08-22 18:05:31 -0400 |
commit | 9d7302299ee96ca954fe4ab8ca640333b6e19ad0 (patch) | |
tree | 6694cfef0d50e53841af9b0954831c03f136af20 /drivers/base/platform.c | |
parent | 5e928f77a09a07f9dd595bb8a489965d69a83458 (diff) |
PM: Run-time PM platform device bus support
This patch adds default Runtime PM callbacks to the dev_pm_ops
belonging to the platform bus. The callbacks are weak symbols
that architecture specific code can override.
Allows Runtime PM even though CONFIG_PM_SLEEP=n.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index d28c289e4a3f..0f7d434ce983 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/bootmem.h> | 17 | #include <linux/bootmem.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/pm_runtime.h> | ||
20 | 21 | ||
21 | #include "base.h" | 22 | #include "base.h" |
22 | 23 | ||
@@ -656,6 +657,13 @@ static void platform_pm_complete(struct device *dev) | |||
656 | drv->pm->complete(dev); | 657 | drv->pm->complete(dev); |
657 | } | 658 | } |
658 | 659 | ||
660 | #else /* !CONFIG_PM_SLEEP */ | ||
661 | |||
662 | #define platform_pm_prepare NULL | ||
663 | #define platform_pm_complete NULL | ||
664 | |||
665 | #endif /* !CONFIG_PM_SLEEP */ | ||
666 | |||
659 | #ifdef CONFIG_SUSPEND | 667 | #ifdef CONFIG_SUSPEND |
660 | 668 | ||
661 | static int platform_pm_suspend(struct device *dev) | 669 | static int platform_pm_suspend(struct device *dev) |
@@ -886,6 +894,31 @@ static int platform_pm_restore_noirq(struct device *dev) | |||
886 | 894 | ||
887 | #endif /* !CONFIG_HIBERNATION */ | 895 | #endif /* !CONFIG_HIBERNATION */ |
888 | 896 | ||
897 | #ifdef CONFIG_PM_RUNTIME | ||
898 | |||
899 | int __weak platform_pm_runtime_suspend(struct device *dev) | ||
900 | { | ||
901 | return -ENOSYS; | ||
902 | }; | ||
903 | |||
904 | int __weak platform_pm_runtime_resume(struct device *dev) | ||
905 | { | ||
906 | return -ENOSYS; | ||
907 | }; | ||
908 | |||
909 | int __weak platform_pm_runtime_idle(struct device *dev) | ||
910 | { | ||
911 | return -ENOSYS; | ||
912 | }; | ||
913 | |||
914 | #else /* !CONFIG_PM_RUNTIME */ | ||
915 | |||
916 | #define platform_pm_runtime_suspend NULL | ||
917 | #define platform_pm_runtime_resume NULL | ||
918 | #define platform_pm_runtime_idle NULL | ||
919 | |||
920 | #endif /* !CONFIG_PM_RUNTIME */ | ||
921 | |||
889 | static const struct dev_pm_ops platform_dev_pm_ops = { | 922 | static const struct dev_pm_ops platform_dev_pm_ops = { |
890 | .prepare = platform_pm_prepare, | 923 | .prepare = platform_pm_prepare, |
891 | .complete = platform_pm_complete, | 924 | .complete = platform_pm_complete, |
@@ -901,22 +934,17 @@ static const struct dev_pm_ops platform_dev_pm_ops = { | |||
901 | .thaw_noirq = platform_pm_thaw_noirq, | 934 | .thaw_noirq = platform_pm_thaw_noirq, |
902 | .poweroff_noirq = platform_pm_poweroff_noirq, | 935 | .poweroff_noirq = platform_pm_poweroff_noirq, |
903 | .restore_noirq = platform_pm_restore_noirq, | 936 | .restore_noirq = platform_pm_restore_noirq, |
937 | .runtime_suspend = platform_pm_runtime_suspend, | ||
938 | .runtime_resume = platform_pm_runtime_resume, | ||
939 | .runtime_idle = platform_pm_runtime_idle, | ||
904 | }; | 940 | }; |
905 | 941 | ||
906 | #define PLATFORM_PM_OPS_PTR (&platform_dev_pm_ops) | ||
907 | |||
908 | #else /* !CONFIG_PM_SLEEP */ | ||
909 | |||
910 | #define PLATFORM_PM_OPS_PTR NULL | ||
911 | |||
912 | #endif /* !CONFIG_PM_SLEEP */ | ||
913 | |||
914 | struct bus_type platform_bus_type = { | 942 | struct bus_type platform_bus_type = { |
915 | .name = "platform", | 943 | .name = "platform", |
916 | .dev_attrs = platform_dev_attrs, | 944 | .dev_attrs = platform_dev_attrs, |
917 | .match = platform_match, | 945 | .match = platform_match, |
918 | .uevent = platform_uevent, | 946 | .uevent = platform_uevent, |
919 | .pm = PLATFORM_PM_OPS_PTR, | 947 | .pm = &platform_dev_pm_ops, |
920 | }; | 948 | }; |
921 | EXPORT_SYMBOL_GPL(platform_bus_type); | 949 | EXPORT_SYMBOL_GPL(platform_bus_type); |
922 | 950 | ||