diff options
Diffstat (limited to 'kernel/time/alarmtimer.c')
-rw-r--r-- | kernel/time/alarmtimer.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 0b8ff7d257ea..ec09ce9a6012 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
29 | #include <linux/freezer.h> | 29 | #include <linux/freezer.h> |
30 | #include <linux/compat.h> | 30 | #include <linux/compat.h> |
31 | #include <linux/module.h> | ||
31 | 32 | ||
32 | #include "posix-timers.h" | 33 | #include "posix-timers.h" |
33 | 34 | ||
@@ -56,9 +57,9 @@ static ktime_t freezer_delta; | |||
56 | static DEFINE_SPINLOCK(freezer_delta_lock); | 57 | static DEFINE_SPINLOCK(freezer_delta_lock); |
57 | #endif | 58 | #endif |
58 | 59 | ||
60 | #ifdef CONFIG_RTC_CLASS | ||
59 | static struct wakeup_source *ws; | 61 | static struct wakeup_source *ws; |
60 | 62 | ||
61 | #ifdef CONFIG_RTC_CLASS | ||
62 | /* rtc timer and device for setting alarm wakeups at suspend */ | 63 | /* rtc timer and device for setting alarm wakeups at suspend */ |
63 | static struct rtc_timer rtctimer; | 64 | static struct rtc_timer rtctimer; |
64 | static struct rtc_device *rtcdev; | 65 | static struct rtc_device *rtcdev; |
@@ -89,6 +90,7 @@ static int alarmtimer_rtc_add_device(struct device *dev, | |||
89 | { | 90 | { |
90 | unsigned long flags; | 91 | unsigned long flags; |
91 | struct rtc_device *rtc = to_rtc_device(dev); | 92 | struct rtc_device *rtc = to_rtc_device(dev); |
93 | struct wakeup_source *__ws; | ||
92 | 94 | ||
93 | if (rtcdev) | 95 | if (rtcdev) |
94 | return -EBUSY; | 96 | return -EBUSY; |
@@ -98,13 +100,25 @@ static int alarmtimer_rtc_add_device(struct device *dev, | |||
98 | if (!device_may_wakeup(rtc->dev.parent)) | 100 | if (!device_may_wakeup(rtc->dev.parent)) |
99 | return -1; | 101 | return -1; |
100 | 102 | ||
103 | __ws = wakeup_source_register("alarmtimer"); | ||
104 | |||
101 | spin_lock_irqsave(&rtcdev_lock, flags); | 105 | spin_lock_irqsave(&rtcdev_lock, flags); |
102 | if (!rtcdev) { | 106 | if (!rtcdev) { |
107 | if (!try_module_get(rtc->owner)) { | ||
108 | spin_unlock_irqrestore(&rtcdev_lock, flags); | ||
109 | return -1; | ||
110 | } | ||
111 | |||
103 | rtcdev = rtc; | 112 | rtcdev = rtc; |
104 | /* hold a reference so it doesn't go away */ | 113 | /* hold a reference so it doesn't go away */ |
105 | get_device(dev); | 114 | get_device(dev); |
115 | ws = __ws; | ||
116 | __ws = NULL; | ||
106 | } | 117 | } |
107 | spin_unlock_irqrestore(&rtcdev_lock, flags); | 118 | spin_unlock_irqrestore(&rtcdev_lock, flags); |
119 | |||
120 | wakeup_source_unregister(__ws); | ||
121 | |||
108 | return 0; | 122 | return 0; |
109 | } | 123 | } |
110 | 124 | ||
@@ -860,7 +874,6 @@ static int __init alarmtimer_init(void) | |||
860 | error = PTR_ERR(pdev); | 874 | error = PTR_ERR(pdev); |
861 | goto out_drv; | 875 | goto out_drv; |
862 | } | 876 | } |
863 | ws = wakeup_source_register("alarmtimer"); | ||
864 | return 0; | 877 | return 0; |
865 | 878 | ||
866 | out_drv: | 879 | out_drv: |