summaryrefslogtreecommitdiff
path: root/rust/kernel/time/hrtimer/pin_mut.rs
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2025-09-22 22:07:40 +0200
committerMiguel Ojeda <ojeda@kernel.org>2025-09-22 22:07:40 +0200
commitcfe872eba9071efe4292caeceaa65d130e4d3974 (patch)
tree2de93821a4bc1566202a6963e715c0fe19c44270 /rust/kernel/time/hrtimer/pin_mut.rs
parent9578c3906c7d9a6f7c1ffefc73a4e8fc3452f336 (diff)
parent4521438fb076f8a6a52f45b0e508f6ef10ac0c49 (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/pin_mut.rs')
-rw-r--r--rust/kernel/time/hrtimer/pin_mut.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/rust/kernel/time/hrtimer/pin_mut.rs b/rust/kernel/time/hrtimer/pin_mut.rs
index 767d0a4e8a2c..9d9447d4d57e 100644
--- a/rust/kernel/time/hrtimer/pin_mut.rs
+++ b/rust/kernel/time/hrtimer/pin_mut.rs
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
use super::{
- HasHrTimer, HrTimer, HrTimerCallback, HrTimerHandle, HrTimerMode, RawHrTimerCallback,
- UnsafeHrTimerPointer,
+ HasHrTimer, HrTimer, HrTimerCallback, HrTimerCallbackContext, HrTimerHandle, HrTimerMode,
+ RawHrTimerCallback, UnsafeHrTimerPointer,
};
use core::{marker::PhantomData, pin::Pin, ptr::NonNull};
@@ -107,6 +107,12 @@ where
// here.
let receiver_pin = unsafe { Pin::new_unchecked(receiver_ref) };
- T::run(receiver_pin).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(receiver_pin, context).into_c()
}
}