aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/alarmtimer.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-04 16:06:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-04 16:06:34 -0400
commitdd90cccffc20a15d8e4c3ac8813f4b6a6cd4766f (patch)
treeb870506b456e3b965638035abb0b2c944b024fd9 /kernel/time/alarmtimer.c
parentb1b6f83ac938d176742c85757960dec2cf10e468 (diff)
parent51218298a25e6942957c5595f2abf130d47d5df9 (diff)
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "A rather small update for the time(r) subsystem: - A new clocksource driver IMX-TPM - Minor fixes to the alarmtimer facility - Device tree cleanups for Renesas drivers - A new kselftest and fixes for the timer related tests - Conversion of the clocksource drivers to use %pOF - Use the proper helpers to access rlimits in the posix-cpu-timer code" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: alarmtimer: Ensure RTC module is not unloaded clocksource: Convert to using %pOF instead of full_name clocksource/drivers/bcm2835: Remove message for a memory allocation failure devicetree: bindings: Remove deprecated properties devicetree: bindings: Remove unused 32-bit CMT bindings devicetree: bindings: Deprecate property, update example devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings devicetree: bindings: Remove sh7372 CMT binding clocksource/drivers/imx-tpm: Add imx tpm timer support dt-bindings: timer: Add nxp tpm timer binding doc posix-cpu-timers: Use dedicated helper to access rlimit values alarmtimer: Fix unavailable wake-up source in sysfs timekeeping: Use proper timekeeper for debug code kselftests: timers: set-timer-lat: Add one-shot timer test cases kselftests: timers: set-timer-lat: Tweak reporting when timer fires early kselftests: timers: freq-step: Fix build warning kselftests: timers: freq-step: Define ADJ_SETOFFSET if device has older kernel headers
Diffstat (limited to 'kernel/time/alarmtimer.c')
-rw-r--r--kernel/time/alarmtimer.c17
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;
56static DEFINE_SPINLOCK(freezer_delta_lock); 57static DEFINE_SPINLOCK(freezer_delta_lock);
57#endif 58#endif
58 59
60#ifdef CONFIG_RTC_CLASS
59static struct wakeup_source *ws; 61static 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 */
63static struct rtc_timer rtctimer; 64static struct rtc_timer rtctimer;
64static struct rtc_device *rtcdev; 65static 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
866out_drv: 879out_drv: