Commit 675e514e authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

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: default avatarAlice Ryhl <aliceryhl@google.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent b69165a0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -217,6 +217,16 @@ pub fn id(&self) -> u32 {
    }
}

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 {