summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-10-21 00:34:28 +0200
committerDanilo Krummrich <dakr@kernel.org>2025-10-29 18:29:32 +0100
commit675e514edd659b5cfc15eb70bd8abf53568947cc (patch)
treed1878e9025a9064991a2628ff0abf6aced78c90e
parentb69165a09727b653993934d700a02d32a8961327 (diff)
rust: auxiliary: implement parent() for Device<Bound>
Take advantage of the fact that if the auxiliary device is bound the parent is guaranteed to be bound as well and implement a separate parent() method for auxiliary::Device<Bound>. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
-rw-r--r--rust/kernel/auxiliary.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index 497601f7473b..cc67fa5ddde3 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -217,6 +217,16 @@ impl<Ctx: device::DeviceContext> Device<Ctx> {
}
}
+impl Device<device::Bound> {
+ /// Returns a bound reference to the parent [`device::Device`].
+ pub fn parent(&self) -> &device::Device<device::Bound> {
+ let parent = (**self).parent();
+
+ // SAFETY: A bound auxiliary device always has a bound parent device.
+ unsafe { parent.as_bound() }
+ }
+}
+
impl Device {
/// Returns a reference to the parent [`device::Device`].
pub fn parent(&self) -> &device::Device {