diff mbox series

[v6,13/18] rust: time: hrtimer: refactor to use `&raw const`

Message ID 20250418014143.888022-14-contact@antoniohickey.com (mailing list archive)
State New
Headers show
Series refactor to utilize `&raw [const|mut]` | expand

Commit Message

Antonio Hickey April 18, 2025, 1:41 a.m. UTC
Replacing all occurrences of `addr_of!(place)` with
`&raw const place`.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const` is similar to `&` making
it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/time/hrtimer.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
index ce53f8579d18..d91d2a655baf 100644
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@ -132,7 +132,7 @@  unsafe fn raw_get(this: *const Self) -> *mut bindings::hrtimer {
         // SAFETY: The field projection to `timer` does not go out of bounds,
         // because the caller of this function promises that `this` points to an
         // allocation of at least the size of `Self`.
-        unsafe { Opaque::raw_get(core::ptr::addr_of!((*this).timer)) }
+        unsafe { Opaque::raw_get(&raw const (*this).timer) }
     }
 
     /// Cancel an initialized and potentially running timer.
@@ -494,7 +494,7 @@  unsafe fn raw_get_timer(
                 this: *const Self,
             ) -> *const $crate::time::hrtimer::HrTimer<$timer_type> {
                 // SAFETY: The caller promises that the pointer is not dangling.
-                unsafe { ::core::ptr::addr_of!((*this).$field) }
+                unsafe { &raw const (*this).$field }
             }
 
             #[inline]