* Re: [PATCH v5 12/17] rust: net: phy: refactor to use `&raw [const|mut]`
@ 2025-03-23 10:39 Benno Lossin
0 siblings, 0 replies; 2+ messages in thread
From: Benno Lossin @ 2025-03-23 10:39 UTC (permalink / raw)
To: Antonio Hickey, FUJITA Tomonori, Trevor Gross, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich
Cc: netdev, rust-for-linux, linux-kernel
On Thu Mar 20, 2025 at 3:07 AM CET, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of_mut!(place)` with
> `&raw mut place`.
>
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw mut` is similar to `&mut`
> 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>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
---
Cheers,
Benno
> ---
> rust/kernel/net/phy.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v5 12/17] rust: net: phy: refactor to use `&raw [const|mut]`
[not found] <20250320020740.1631171-1-contact@antoniohickey.com>
@ 2025-03-20 2:07 ` Antonio Hickey
0 siblings, 0 replies; 2+ messages in thread
From: Antonio Hickey @ 2025-03-20 2:07 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich
Cc: Antonio Hickey, netdev, rust-for-linux, linux-kernel
Replacing all occurrences of `addr_of_mut!(place)` with
`&raw mut place`.
This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw mut` is similar to `&mut`
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/net/phy.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index a59469c785e3..757db052cc09 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -7,7 +7,7 @@
//! C headers: [`include/linux/phy.h`](srctree/include/linux/phy.h).
use crate::{error::*, prelude::*, types::Opaque};
-use core::{marker::PhantomData, ptr::addr_of_mut};
+use core::marker::PhantomData;
pub mod reg;
@@ -285,7 +285,7 @@ impl AsRef<kernel::device::Device> for Device {
fn as_ref(&self) -> &kernel::device::Device {
let phydev = self.0.get();
// SAFETY: The struct invariant ensures that `mdio.dev` is valid.
- unsafe { kernel::device::Device::as_ref(addr_of_mut!((*phydev).mdio.dev)) }
+ unsafe { kernel::device::Device::as_ref(&raw mut (*phydev).mdio.dev) }
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-23 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-23 10:39 [PATCH v5 12/17] rust: net: phy: refactor to use `&raw [const|mut]` Benno Lossin
[not found] <20250320020740.1631171-1-contact@antoniohickey.com>
2025-03-20 2:07 ` Antonio Hickey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®