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 <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Tested-by: Daniel Almeida <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: FUJITA Tomonori <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Hindborg <[email protected]>
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)