rtc_read_next_alarm(9)
π rtc_read_next_alarm(9) π
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:
rtc_handle_legacy_irq(9)rtc_aie_update_irq(9)rtc_uie_update_irq(9)rtc_pie_update_irq(9)rtc_update_irq(9)rtc_irq_set_state(9)rtc_irq_set_freq(9)rtc_timer_enqueue(9)rtc_timer_remove(9)rtc_timer_do_work(9)rtc_read_offset(9)rtc_set_offset(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms