rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust/time: Add Delta::from_nanos()
@ 2025-11-14 18:42 Lyude Paul
  2025-11-16  6:38 ` Onur Özkan
  2025-11-17  1:39 ` FUJITA Tomonori
  0 siblings, 2 replies; 8+ messages in thread
From: Lyude Paul @ 2025-11-14 18:42 UTC (permalink / raw)
  To: rust-for-linux, linux-kernel
  Cc: Andreas Hindborg, Boqun Feng, FUJITA Tomonori,
	Frederic Weisbecker, Thomas Gleixner, Anna-Maria Behnsen,
	John Stultz, Stephen Boyd, Miguel Ojeda, Alex Gaynor, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich

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>
---
 rust/kernel/time.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
index 6ea98dfcd0278..2b096e5a61cda 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.

base-commit: 5935461b458463ee51aac8d95c25d7a5e1de8c4d
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-11-17 12:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 18:42 [PATCH] rust/time: Add Delta::from_nanos() Lyude Paul
2025-11-16  6:38 ` Onur Özkan
2025-11-16 11:06   ` Miguel Ojeda
2025-11-17 10:21     ` Onur Özkan
2025-11-17  1:39 ` FUJITA Tomonori
2025-11-17 11:15   ` Andreas Hindborg
2025-11-17 11:38     ` FUJITA Tomonori
2025-11-17 12:26       ` Andreas Hindborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).