summaryrefslogtreecommitdiffstats
path: root/rust/kernel/time/hrtimer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/time/hrtimer.rs')
-rw-r--r--rust/kernel/time/hrtimer.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
index bfb536f2a490..bc8f85cededb 100644
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@ -212,7 +212,7 @@ pub trait HrTimerCallback {
type Pointer<'a>: RawHrTimerCallback;
/// Called by the timer logic when the timer fires.
- fn run(this: <Self::Pointer<'_> as RawHrTimerCallback>::CallbackTarget<'_>)
+ fn run(this: <Self::Pointer<'_> as RawHrTimerCallback>::CallbackTarget<'_>) -> HrTimerRestart
where
Self: Sized;
}
@@ -311,6 +311,24 @@ pub unsafe trait HasHrTimer<T> {
}
}
+/// Restart policy for timers.
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+#[repr(u32)]
+pub enum HrTimerRestart {
+ /// Timer should not be restarted.
+ #[allow(clippy::unnecessary_cast)]
+ NoRestart = bindings::hrtimer_restart_HRTIMER_NORESTART as u32,
+ /// Timer should be restarted.
+ #[allow(clippy::unnecessary_cast)]
+ Restart = bindings::hrtimer_restart_HRTIMER_RESTART as u32,
+}
+
+impl HrTimerRestart {
+ fn into_c(self) -> bindings::hrtimer_restart {
+ self as bindings::hrtimer_restart
+ }
+}
+
/// Use to implement the [`HasHrTimer<T>`] trait.
///
/// See [`module`] documentation for an example.