summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-10-21 00:34:25 +0200
committerDanilo Krummrich <dakr@kernel.org>2025-10-29 18:29:32 +0100
commit589b061975db3c7e87b819cc9a8006eb99ac4b5f (patch)
tree838952fca95ab6006909560fa441bca6eabccfb6 /rust/kernel
parent6f61a2637abe4f89877da3280775565baedb60e0 (diff)
rust: auxiliary: consider auxiliary devices always have a parent
An auxiliary device is guaranteed to always have a parent device (both in C and Rust), hence don't return an Option<&auxiliary::Device> in auxiliary::Device::parent(). Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/auxiliary.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index a6a2b23befce..e5bddb738d58 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -215,9 +215,10 @@ impl<Ctx: device::DeviceContext> Device<Ctx> {
unsafe { (*self.as_raw()).id }
}
- /// Returns a reference to the parent [`device::Device`], if any.
- pub fn parent(&self) -> Option<&device::Device> {
- self.as_ref().parent()
+ /// Returns a reference to the parent [`device::Device`].
+ pub fn parent(&self) -> &device::Device {
+ // SAFETY: A `struct auxiliary_device` always has a parent.
+ unsafe { self.as_ref().parent().unwrap_unchecked() }
}
}