diff options
| author | Andreas Hindborg <[email protected]> | 2025-03-09 15:18:55 +0000 |
|---|---|---|
| committer | Andreas Hindborg <[email protected]> | 2025-03-22 11:08:54 +0000 |
| commit | 94e05a66ea3ebed48e7e1a0dee68d40184386d25 (patch) | |
| tree | 4f91923eead6f5ad57528fb94c542fca285b2d85 | |
| parent | rust: hrtimer: implement `HrTimerPointer` for `Arc` (diff) | |
| download | kernel-94e05a66ea3ebed48e7e1a0dee68d40184386d25.tar.gz kernel-94e05a66ea3ebed48e7e1a0dee68d40184386d25.zip | |
rust: hrtimer: allow timer restart from timer handler
Allow timer handlers to report that they want a timer to be restarted after
the timer handler has finished executing.
Acked-by: Frederic Weisbecker <[email protected]>
Acked-by: Thomas Gleixner <[email protected]>
Reviewed-by: Benno Lossin <[email protected]>
Reviewed-by: Tamir Duberstein <[email protected]>
Reviewed-by: Lyude Paul <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Andreas Hindborg <[email protected]>
| -rw-r--r-- | rust/kernel/time/hrtimer.rs | 20 | ||||
| -rw-r--r-- | rust/kernel/time/hrtimer/arc.rs | 4 |
2 files changed, 20 insertions, 4 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. diff --git a/rust/kernel/time/hrtimer/arc.rs b/rust/kernel/time/hrtimer/arc.rs index df97fade0aa1..4a984d85b4a1 100644 --- a/rust/kernel/time/hrtimer/arc.rs +++ b/rust/kernel/time/hrtimer/arc.rs @@ -95,8 +95,6 @@ where // allocation from other `Arc` clones. let receiver = unsafe { ArcBorrow::from_raw(data_ptr) }; - T::run(receiver); - - bindings::hrtimer_restart_HRTIMER_NORESTART + T::run(receiver).into_c() } } |
