summaryrefslogtreecommitdiff
path: root/rust/kernel/platform.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/platform.rs')
-rw-r--r--rust/kernel/platform.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index 4917cb34e2fe..22590bdff7bb 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -16,7 +16,6 @@ use crate::{
use core::{
marker::PhantomData,
- ops::Deref,
ptr::{addr_of_mut, NonNull},
};
@@ -190,19 +189,9 @@ impl Device {
}
}
-impl Deref for Device<device::Core> {
- type Target = Device;
-
- fn deref(&self) -> &Self::Target {
- let ptr: *const Self = self;
-
- // CAST: `Device<Ctx>` is a transparent wrapper of `Opaque<bindings::platform_device>`.
- let ptr = ptr.cast::<Device>();
-
- // SAFETY: `ptr` was derived from `&self`.
- unsafe { &*ptr }
- }
-}
+// SAFETY: `Device` is a transparent wrapper of a type that doesn't depend on `Device`'s generic
+// argument.
+kernel::impl_device_context_deref!(unsafe { Device });
impl From<&Device<device::Core>> for ARef<Device> {
fn from(dev: &Device<device::Core>) -> Self {