]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: hrtimer: Add HrTimerInstant
authorLyude Paul <lyude@redhat.com>
Thu, 21 Aug 2025 19:32:42 +0000 (15:32 -0400)
committerAndreas Hindborg <a.hindborg@kernel.org>
Thu, 4 Sep 2025 14:54:39 +0000 (16:54 +0200)
Since we want to add HrTimer methods that can accept Instants, we will want
to make sure that for each method we are using the correct Clocksource for
the given HrTimer. This would get a bit overly-verbose, so add a simple
HrTimerInstant type-alias to handle this for us.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250821193259.964504-3-lyude@redhat.com
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
rust/kernel/time/hrtimer.rs

index 6bfc0223f4f579b8e8875d4885c952d340e2af44..be1bad4aacaad8a0d88aa7eb0719d409c55ea422 100644 (file)
@@ -72,6 +72,11 @@ use crate::{prelude::*, types::Opaque};
 use core::marker::PhantomData;
 use pin_init::PinInit;
 
+/// A type-alias to refer to the [`Instant<C>`] for a given `T` from [`HrTimer<T>`].
+///
+/// Where `C` is the [`ClockSource`] of the [`HrTimer`].
+pub type HrTimerInstant<T> = Instant<<<T as HasHrTimer<T>>::TimerMode as HrTimerMode>::Clock>;
+
 /// A timer backed by a C `struct hrtimer`.
 ///
 /// # Invariants