Skip to content

Commit 7c94cac

Browse files
bebarinoKAGA-KOKO
authored andcommitted
alarmtimer: Use wakeup source from alarmtimer platform device
Use the wakeup source that can be associated with the 'alarmtimer' platform device instead of registering another one by hand. Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c79108b commit 7c94cac

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

kernel/time/alarmtimer.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ static DEFINE_SPINLOCK(freezer_delta_lock);
5858
#endif
5959

6060
#ifdef CONFIG_RTC_CLASS
61-
static struct wakeup_source *ws;
62-
6361
/* rtc timer and device for setting alarm wakeups at suspend */
6462
static struct rtc_timer rtctimer;
6563
static struct rtc_device *rtcdev;
@@ -88,7 +86,6 @@ static int alarmtimer_rtc_add_device(struct device *dev,
8886
{
8987
unsigned long flags;
9088
struct rtc_device *rtc = to_rtc_device(dev);
91-
struct wakeup_source *__ws;
9289
struct platform_device *pdev;
9390
int ret = 0;
9491

@@ -100,12 +97,13 @@ static int alarmtimer_rtc_add_device(struct device *dev,
10097
if (!device_may_wakeup(rtc->dev.parent))
10198
return -1;
10299

103-
__ws = wakeup_source_register(dev, "alarmtimer");
104100
pdev = platform_device_register_data(dev, "alarmtimer",
105101
PLATFORM_DEVID_AUTO, NULL, 0);
102+
if (!IS_ERR(pdev))
103+
device_init_wakeup(&pdev->dev, true);
106104

107105
spin_lock_irqsave(&rtcdev_lock, flags);
108-
if (__ws && !IS_ERR(pdev) && !rtcdev) {
106+
if (!IS_ERR(pdev) && !rtcdev) {
109107
if (!try_module_get(rtc->owner)) {
110108
ret = -1;
111109
goto unlock;
@@ -114,8 +112,6 @@ static int alarmtimer_rtc_add_device(struct device *dev,
114112
rtcdev = rtc;
115113
/* hold a reference so it doesn't go away */
116114
get_device(dev);
117-
ws = __ws;
118-
__ws = NULL;
119115
pdev = NULL;
120116
} else {
121117
ret = -1;
@@ -124,7 +120,6 @@ static int alarmtimer_rtc_add_device(struct device *dev,
124120
spin_unlock_irqrestore(&rtcdev_lock, flags);
125121

126122
platform_device_unregister(pdev);
127-
wakeup_source_unregister(__ws);
128123

129124
return ret;
130125
}
@@ -291,7 +286,7 @@ static int alarmtimer_suspend(struct device *dev)
291286
return 0;
292287

293288
if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) {
294-
__pm_wakeup_event(ws, 2 * MSEC_PER_SEC);
289+
pm_wakeup_event(dev, 2 * MSEC_PER_SEC);
295290
return -EBUSY;
296291
}
297292

@@ -306,7 +301,7 @@ static int alarmtimer_suspend(struct device *dev)
306301
/* Set alarm, if in the past reject suspend briefly to handle */
307302
ret = rtc_timer_start(rtc, &rtctimer, now, 0);
308303
if (ret < 0)
309-
__pm_wakeup_event(ws, MSEC_PER_SEC);
304+
pm_wakeup_event(dev, MSEC_PER_SEC);
310305
return ret;
311306
}
312307

0 commit comments

Comments
 (0)