From 675e514edd659b5cfc15eb70bd8abf53568947cc Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Tue, 21 Oct 2025 00:34:28 +0200 Subject: [PATCH] rust: auxiliary: implement parent() for Device 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. Reviewed-by: Alice Ryhl Reviewed-by: Greg Kroah-Hartman Signed-off-by: Danilo Krummrich --- rust/kernel/auxiliary.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs index 497601f7473bf..cc67fa5ddde30 100644 --- a/rust/kernel/auxiliary.rs +++ b/rust/kernel/auxiliary.rs @@ -217,6 +217,16 @@ impl Device { } } +impl Device { + /// Returns a bound reference to the parent [`device::Device`]. + pub fn parent(&self) -> &device::Device { + 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 { -- 2.47.3