Skip to content

Commit 3caad57

Browse files
fujitaAndreas Hindborg
authored andcommitted
rust: time: Add PartialEq/Eq/PartialOrd/Ord trait to Ktime
Add PartialEq/Eq/PartialOrd/Ord trait to Ktime so two Ktime instances can be compared to determine whether a timeout is met or not. Use the derive implements; we directly touch C's ktime_t rather than using the C's accessors because it is more efficient and we already do in the existing code (Ktime::sub). Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Fiona Behrens <me@kloenk.dev> Tested-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/r/20250423192857.199712-3-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
1 parent 1116f0c commit 3caad57

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/kernel/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn msecs_to_jiffies(msecs: Msecs) -> Jiffies {
2929

3030
/// A Rust wrapper around a `ktime_t`.
3131
#[repr(transparent)]
32-
#[derive(Copy, Clone)]
32+
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord)]
3333
pub struct Ktime {
3434
inner: bindings::ktime_t,
3535
}

0 commit comments

Comments
 (0)