rtc_read_next_alarm(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

okay so this is a page straight out of the Kernel API Manual β€” it's rtc_read_next_alarm(9), bestie, and it's genuinely one of the more useful little gremlins in the RTC toolbox. let's get into it πŸ•°οΈβœ¨


✨ NAME ✨

rtc_read_next_alarm β€” read the next expiring alarm πŸ””

like, the alarm that's actually gonna go off next. not the one you think is next. the real one. iykyk.


🌸 SYNOPSIS 🌸

int rtc_read_next_alarm (struct rtc_device *rtc , struct rtc_wkalrm
*alarm );

that's the whole signature, no cap β€” it takes two pointers and hands you back an int. 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • rtc β€” the RTC device 🌈 (your real-time clock, the literal main character here)
  • alarm β€” storage for the alarm information πŸ“ (this is where the answer lands, so pls make sure it points somewhere valid)

πŸ’… DESCRIPTION πŸ’…

so the way that this works: it reads the next expiring alarm from the RTC timerqueue. that's it, that's the vibe. ⏰

the important lil twist? it returns the alarm that will actually fire next, which β€” and this is the part that gets people β€” may be different from rtc_read_alarm if multiple timers are queued. the page literally calls out the example for you: like when alarmtimer and wakealarm sysfs are both active. 😭 two timers, one queue, and you wanna know which one's up first β€” that's this function, fr fr.

not me needing to re-read this three times the first time i saw it β€” the "may be different" thing is the entire personality of this function, don't skip it πŸ™ˆ

πŸ”₯ RETURN πŸ”₯

  • 0 β€” success, we ate πŸ’–
  • -ENOENT β€” no alarm is pending, so like… nothing's queued, bestie, go home 🫠
  • or other error β€” because of course there could be other errors, it's kernel code πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./drivers/rtc/interface.c, plus the whole friend group:

go read the whole squad, they're all iconic in their own way 🌟


⭐ tiny sign-off: this lil page lives in ./drivers/rtc and it's dated October 2026 β€” so yeah, it's giving slightly-from-the-future energy πŸ‘‘πŸ’œ go forth and read your next expiring alarm correctly, bestie πŸ’…βœ¨
πŸ“¦ where this page comes from