diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2025-06-10 22:28:21 +0900 |
---|---|---|
committer | Andreas Hindborg <a.hindborg@kernel.org> | 2025-06-24 19:52:47 +0200 |
commit | d9fc00dc73542eef98db74085447c57174ca290d (patch) | |
tree | 5b3c3f06c0c96698d02a6f6759148a502afec7f0 /rust/kernel/time.rs | |
parent | ced9ccd21fbc8ca941e6a0c2820c2df89239ccb9 (diff) |
rust: time: Add HrTimerExpires trait
Introduce the `HrTimerExpires` trait to represent types that can be
used as expiration values for high-resolution timers. Define a
required method, `into_nanos()`, which returns the expiration time as a
raw nanosecond value suitable for use with C's hrtimer APIs.
Also extend the `HrTimerMode` to use the `HrTimerExpires` trait.
This refactoring is a preparation for enabling hrtimer code to work
uniformly with both absolute and relative expiration modes.
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://lore.kernel.org/r/20250610132823.3457263-4-fujita.tomonori@gmail.com
[ changed conversion method names to `as_*` - Andreas ]
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Diffstat (limited to 'rust/kernel/time.rs')
-rw-r--r-- | rust/kernel/time.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs index 1be5ecd814d3..5a9ca0d3b7d4 100644 --- a/rust/kernel/time.rs +++ b/rust/kernel/time.rs @@ -194,6 +194,11 @@ impl<C: ClockSource> Instant<C> { pub fn elapsed(&self) -> Delta { Self::now() - *self } + + #[inline] + pub(crate) fn as_nanos(&self) -> i64 { + self.inner + } } impl<C: ClockSource> core::ops::Sub for Instant<C> { |