diff options
author | Miguel Ojeda <ojeda@kernel.org> | 2025-09-22 22:07:40 +0200 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2025-09-22 22:07:40 +0200 |
commit | cfe872eba9071efe4292caeceaa65d130e4d3974 (patch) | |
tree | 2de93821a4bc1566202a6963e715c0fe19c44270 /rust/kernel/time/hrtimer/tbox.rs | |
parent | 9578c3906c7d9a6f7c1ffefc73a4e8fc3452f336 (diff) | |
parent | 4521438fb076f8a6a52f45b0e508f6ef10ac0c49 (diff) |
Merge tag 'rust-timekeeping-v6.18' of https://github.com/Rust-for-Linux/linux into rust-next
Pull timekeeping updates from Andreas Hindborg:
- Add methods on 'HrTimer' that can only be called with exclusive
access to an unarmed timer, or form timer callback context.
- Add arithmetic operations to 'Instant' and 'Delta'.
- Add a few convenience and access methods to 'HrTimer' and 'Instant'.
* tag 'rust-timekeeping-v6.18' of https://github.com/Rust-for-Linux/linux:
rust: time: Implement basic arithmetic operations for Delta
rust: time: Implement Add<Delta>/Sub<Delta> for Instant
rust: hrtimer: Add HrTimer::expires()
rust: time: Add Instant::from_ktime()
rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext
rust: hrtimer: Add HrTimerCallbackContext and ::forward()
rust: hrtimer: Add HrTimer::raw_forward() and forward()
rust: hrtimer: Add HrTimerInstant
rust: hrtimer: Document the return value for HrTimerHandle::cancel()
Diffstat (limited to 'rust/kernel/time/hrtimer/tbox.rs')
-rw-r--r-- | rust/kernel/time/hrtimer/tbox.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/rust/kernel/time/hrtimer/tbox.rs b/rust/kernel/time/hrtimer/tbox.rs index ec08303315f2..aa1ee31a7195 100644 --- a/rust/kernel/time/hrtimer/tbox.rs +++ b/rust/kernel/time/hrtimer/tbox.rs @@ -3,6 +3,7 @@ use super::HasHrTimer; use super::HrTimer; use super::HrTimerCallback; +use super::HrTimerCallbackContext; use super::HrTimerHandle; use super::HrTimerMode; use super::HrTimerPointer; @@ -119,6 +120,12 @@ where // `data_ptr` exist. let data_mut_ref = unsafe { Pin::new_unchecked(&mut *data_ptr) }; - T::run(data_mut_ref).into_c() + // SAFETY: + // - By C API contract `timer_ptr` is the pointer that we passed when queuing the timer, so + // it is a valid pointer to a `HrTimer<T>` embedded in a `T`. + // - We are within `RawHrTimerCallback::run` + let context = unsafe { HrTimerCallbackContext::from_raw(timer_ptr) }; + + T::run(data_mut_ref, context).into_c() } } |