@@ -1199,30 +1199,27 @@ fn wfi_raw(event_mask: u32, timeout: I2cTimeout) -> I2cControlResult {
11991199 loop {
12001200 let received = sys_recv_notification ( event_mask | TIMER_NOTIFICATION ) ;
12011201
1202- // If the event arrived _and_ our timer went off, prioritize the event and
1203- // ignore the timeout.
1204- if received & event_mask != 0 {
1202+ // If the event arrived _and_ our timer went off, prioritize the event
1203+ // and ignore the timeout.
1204+ if received. check_notification_mask ( event_mask) {
12051205 // Attempt to clear our timer. Note that this does not protect against
12061206 // the race where the kernel decided to wake us up, but the timer went
12071207 // off before we got to this point.
12081208 sys_set_timer ( None , TIMER_NOTIFICATION ) ;
12091209 break I2cControlResult :: Interrupted ;
1210- } else {
1211- // The timer bit must have been set. Verify that our timer has
1212- // actually expired:
1213- if sys_get_timer ( ) . now >= dead {
1214- break I2cControlResult :: TimedOut ;
1215- }
1216-
1217- // Otherwise, one of two things has happened:
1218- // 1. Some joker has posted to our timer bit. Ha ha very funny.
1219- // 2. The timer bit was _already set_ on entry to this routine, as a
1220- // hangover from a previous run.
1221- //
1222- // We don't need to re-set our timer here because we sampled
1223- // sys_get_timer _after_ receiving notifications, meaning it either
1224- // hasn't gone off, or it has gone off but that fact is still stored
1225- // in our notification bits.
1210+ } else if received. check_timer ( TIMER_NOTIFICATION ) {
1211+ // The timer has actually expired!
1212+ break I2cControlResult :: TimedOut ;
12261213 }
1214+
1215+ // Otherwise, one of two things has happened:
1216+ // 1. Some joker has posted to our timer bit. Ha ha very funny.
1217+ // 2. The timer bit was _already set_ on entry to this routine, as a
1218+ // hangover from a previous run.
1219+ //
1220+ // We don't need to re-set our timer here because we sampled
1221+ // sys_get_timer _after_ receiving notifications, meaning it either
1222+ // hasn't gone off, or it has gone off but that fact is still stored in
1223+ // our notification bits.
12271224 }
12281225}
0 commit comments