From: FUJITA Tomonori Date: Wed, 23 Apr 2025 19:28:52 +0000 (+0900) Subject: rust: time: Add PartialEq/Eq/PartialOrd/Ord trait to Ktime X-Git-Tag: v6.16-rc1~45^2~36^2~3 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=3caad57d29b5f64fa41cff0b12cc5d9144dacb04;p=linux-block.git 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 Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Reviewed-by: Fiona Behrens Tested-by: Daniel Almeida Reviewed-by: Andreas Hindborg Signed-off-by: FUJITA Tomonori Link: https://lore.kernel.org/r/20250423192857.199712-3-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg --- diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs index f509cb0eb71e..9d57e8a5552a 100644 --- a/rust/kernel/time.rs +++ b/rust/kernel/time.rs @@ -29,7 +29,7 @@ pub fn msecs_to_jiffies(msecs: Msecs) -> Jiffies { /// A Rust wrapper around a `ktime_t`. #[repr(transparent)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord)] pub struct Ktime { inner: bindings::ktime_t, }