Re: [PATCH v3 02/13] rust: hrtimer: introduce hrtimer support
From: Thomas Gleixner
Date: Wed Nov 06 2024 - 20:55:35 EST
Andreas!
On Thu, Oct 17 2024 at 15:04, Andreas Hindborg wrote:
> +impl<T> Timer<T> {
> + /// Return an initializer for a new timer instance.
> + pub fn new() -> impl PinInit<Self>
> + where
> + T: TimerCallback,
> + {
> + pin_init!(Self {
> + // INVARIANTS: We initialize `timer` with `hrtimer_init` below.
> + timer <- Opaque::ffi_init(move |place: *mut bindings::hrtimer| {
> + // SAFETY: By design of `pin_init!`, `place` is a pointer live
> + // allocation. hrtimer_init will initialize `place` and does not
> + // require `place` to be initialized prior to the call.
> + unsafe {
> + bindings::hrtimer_init(
> + place,
> + bindings::CLOCK_MONOTONIC as i32,
> + bindings::hrtimer_mode_HRTIMER_MODE_REL,
> + );
> + }
> +
> + // SAFETY: `place` is pointing to a live allocation, so the deref
> + // is safe.
> + let function =
> + unsafe { core::ptr::addr_of_mut!((*place).function) };
I assume you are sending a new version of this series due to the
reported build issue.
If so, can you please rebase against
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
It contains the new hrtimer_setup() function, which initializes the
timer including the callback function pointer.
Thanks,
tglx