]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust/time: Add Delta::from_nanos()
authorLyude Paul <lyude@redhat.com>
Fri, 14 Nov 2025 18:42:06 +0000 (13:42 -0500)
committerAndreas Hindborg <a.hindborg@kernel.org>
Mon, 23 Mar 2026 07:29:48 +0000 (08:29 +0100)
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>
rust/kernel/time.rs

index 6ea98dfcd027871848981ef8d6c4714216d77e2c..2b096e5a61cda5c9c48e3a300b3b887ec1d402a0 100644 (file)
@@ -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.