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>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user