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: move parent() to impl Device

Currently, the parent method is implemented for any Device<Ctx>, i.e.
any device context and returns a &device::Device<Normal>.

However, a subsequent patch will introduce

impl Device<Bound> {
pub fn parent() -> device::Device<Bound> { ... }
}

which takes advantage of the fact that if the auxiliary device is bound
the parent is guaranteed to be bound as well.

I.e. the behavior we want is that all device contexts that dereference
to Bound, will use the implementation above, whereas the old
implementation should only be implemented for Device<Normal>.

Hence, move the current implementation.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+2 -2
+2 -2
rust/kernel/auxiliary.rs
··· 215 215 // `struct auxiliary_device`. 216 216 unsafe { (*self.as_raw()).id } 217 217 } 218 + } 218 219 220 + impl Device { 219 221 /// Returns a reference to the parent [`device::Device`]. 220 222 pub fn parent(&self) -> &device::Device { 221 223 // SAFETY: A `struct auxiliary_device` always has a parent. 222 224 unsafe { self.as_ref().parent().unwrap_unchecked() } 223 225 } 224 - } 225 226 226 - impl Device { 227 227 extern "C" fn release(dev: *mut bindings::device) { 228 228 // SAFETY: By the type invariant `self.0.as_raw` is a pointer to the `struct device` 229 229 // embedded in `struct auxiliary_device`.