public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: time: add `Delta::from_nanos`
@ 2026-02-15 20:12 Andreas Hindborg
  2026-02-16  8:33 ` Alice Ryhl
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Hindborg @ 2026-02-15 20:12 UTC (permalink / raw)
  To: Boqun Feng, FUJITA Tomonori, Frederic Weisbecker, Lyude Paul,
	Thomas Gleixner, Anna-Maria Behnsen, John Stultz, Stephen Boyd,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Alice Ryhl, Trevor Gross, Danilo Krummrich
  Cc: rust-for-linux, linux-kernel, Andreas Hindborg

Add a method to create a `Delta` from an amount of nanoseconds.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
 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: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260215-time-from-nanos-86f8b10be4a2

Best regards,
-- 
Andreas Hindborg <a.hindborg@kernel.org>



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

* Re: [PATCH] rust: time: add `Delta::from_nanos`
  2026-02-15 20:12 [PATCH] rust: time: add `Delta::from_nanos` Andreas Hindborg
@ 2026-02-16  8:33 ` Alice Ryhl
  2026-02-16 13:38   ` Andreas Hindborg
  0 siblings, 1 reply; 3+ messages in thread
From: Alice Ryhl @ 2026-02-16  8:33 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Boqun Feng, FUJITA Tomonori, Frederic Weisbecker, Lyude Paul,
	Thomas Gleixner, Anna-Maria Behnsen, John Stultz, Stephen Boyd,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel

On Sun, Feb 15, 2026 at 09:12:04PM +0100, Andreas Hindborg wrote:
> Add a method to create a `Delta` from an amount of nanoseconds.
> 
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>

The change itself LGTM, but what is this for?

Reviewed-by: Alice Ryhl <aliceryhl@google.com>


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

* Re: [PATCH] rust: time: add `Delta::from_nanos`
  2026-02-16  8:33 ` Alice Ryhl
@ 2026-02-16 13:38   ` Andreas Hindborg
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Hindborg @ 2026-02-16 13:38 UTC (permalink / raw)
  To: Alice Ryhl
  Cc: Boqun Feng, FUJITA Tomonori, Frederic Weisbecker, Lyude Paul,
	Thomas Gleixner, Anna-Maria Behnsen, John Stultz, Stephen Boyd,
	Miguel Ojeda, Gary Guo, Björn Roy Baron, Benno Lossin,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel

"Alice Ryhl" <aliceryhl@google.com> writes:

> On Sun, Feb 15, 2026 at 09:12:04PM +0100, Andreas Hindborg wrote:
>> Add a method to create a `Delta` from an amount of nanoseconds.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> The change itself LGTM, but what is this for?

There is a few uses in the rust null block series. For compatibility
reasons, some config options are given as nano seconds [1].

>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Thanks.

Best regards,
Andreas Hindborg

[1] https://lore.kernel.org/r/20260216-rnull-v6-19-rc5-send-v1-8-de9a7af4b469@kernel.org


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

end of thread, other threads:[~2026-02-16 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-15 20:12 [PATCH] rust: time: add `Delta::from_nanos` Andreas Hindborg
2026-02-16  8:33 ` Alice Ryhl
2026-02-16 13:38   ` Andreas Hindborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox