diff options
| -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 | ||
