[PATCH v6 16/18] rust: dma: refactor to use `&raw [const|mut]`

From: Antonio Hickey
Date: Thu Apr 17 2025 - 21:46:15 EST


Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

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

Suggested-by: Benno Lossin <benno.lossin@xxxxxxxxx>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@xxxxxxxxxxxxxxxxx>
---
rust/kernel/dma.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 8cdc76043ee7..8a63c0e83c92 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -333,7 +333,7 @@ macro_rules! dma_read {
// dereferenced. The compiler also further validates the expression on whether `field`
// is a member of `item` when expanded by the macro.
unsafe {
- let ptr_field = ::core::ptr::addr_of!((*item) $($field)*);
+ let ptr_field = &raw const ((*item) $($field)*);
$crate::dma::CoherentAllocation::field_read(&$dma, ptr_field)
}
}};
@@ -384,7 +384,7 @@ macro_rules! dma_write {
// dereferenced. The compiler also further validates the expression on whether `field`
// is a member of `item` when expanded by the macro.
unsafe {
- let ptr_field = ::core::ptr::addr_of_mut!((*item) $(.$field)*);
+ let ptr_field = &raw mut ((*item) $(.$field)*);
$crate::dma::CoherentAllocation::field_write(&$dma, ptr_field, $val)
}
};
--
2.48.1