diff options
| author | Lyude Paul <lyude@redhat.com> | 2025-11-14 13:42:06 -0500 |
|---|---|---|
| committer | Andreas Hindborg <a.hindborg@kernel.org> | 2026-03-23 08:29:48 +0100 |
| commit | c51866f65b8ac37b8883a2e80ada13c8cd4d2f7b (patch) | |
| tree | 91d8e7077c85bd26977900f7b70967cee3e82054 /rust/kernel | |
| parent | c369299895a591d96745d6492d4888259b004a9e (diff) | |
| download | linux-c51866f65b8ac37b8883a2e80ada13c8cd4d2f7b.tar.gz linux-c51866f65b8ac37b8883a2e80ada13c8cd4d2f7b.zip | |
rust/time: Add Delta::from_nanos()
Since rvkms is going to need to create its own Delta instances, and we
already have functions for creating Delta with every other unit of time.
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://msgid.link/20251114184207.459335-1-lyude@redhat.com
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Diffstat (limited to 'rust/kernel')
| -rw-r--r-- | rust/kernel/time.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs index 6ea98dfcd027..2b096e5a61cd 100644 --- a/rust/kernel/time.rs +++ b/rust/kernel/time.rs @@ -363,6 +363,12 @@ impl Delta { /// A span of time equal to zero. pub const ZERO: Self = Self { nanos: 0 }; + /// Create a new [`Delta`] from a number of nanoseconds. + #[inline] + pub const fn from_nanos(nanos: i64) -> Self { + Self { nanos } + } + /// Create a new [`Delta`] from a number of microseconds. /// /// The `micros` can range from -9_223_372_036_854_775 to 9_223_372_036_854_775. |
