[tip: timers/core] alarmtimer: Initialize the device wakeup after the RTC device was chosen

From: tip-bot2 for Thomas Weißschuh

Date: Mon Nov 30 2026 - 10:12:28 EST


The following commit has been merged into the timers/core branch of tip:

Commit-ID: cef1829ad349333a2fe847f6fba9d9b3aa8f33da
Gitweb: https://git.kernel.org/tip/cef1829ad349333a2fe847f6fba9d9b3aa8f33da
Author: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
AuthorDate: Tue, 10 Nov 2026 12:25:20
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Mon, 30 Nov 2026 16:08:41 +01:00

alarmtimer: Initialize the device wakeup after the RTC device was chosen

Currently device_init_wakeup() is called before try_module_get().
If try_module_get() fails the wakeup enablement has been pointless.

Only call device_init_wakeup() after the device has been chosen as RTC
device definitively.

Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://lore.kernel.org/lkml/878q31vl8g.ffs@fw13/
Link: https://patch.msgid.link/20261110-alarmtimer-wakeup-v1-1-af4269645dec@xxxxxxxxxxxxxx
---
kernel/time/alarmtimer.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index ecf8c89..da6b302 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -91,13 +91,12 @@ static int alarmtimer_rtc_add_device(struct device *dev)
if (IS_ERR(pdev))
return PTR_ERR(pdev);

- device_init_wakeup(&pdev->dev, true);
-
if (!try_module_get(rtc->owner)) {
platform_device_unregister(pdev);
return -1;
}

+ device_init_wakeup(&pdev->dev, true);
WRITE_ONCE(rtcdev, rtc);
/* Hold a reference so it doesn't go away */
get_device(dev);