Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+10
+10
rust/kernel/auxiliary.rs
··· 217 217 } 218 218 } 219 219 220 + impl Device<device::Bound> { 221 + /// Returns a bound reference to the parent [`device::Device`]. 222 + pub fn parent(&self) -> &device::Device<device::Bound> { 223 + let parent = (**self).parent(); 224 + 225 + // SAFETY: A bound auxiliary device always has a bound parent device. 226 + unsafe { parent.as_bound() } 227 + } 228 + } 229 + 220 230 impl Device { 221 231 /// Returns a reference to the parent [`device::Device`]. 222 232 pub fn parent(&self) -> &device::Device {