From: Danilo Krummrich Date: Mon, 20 Oct 2025 22:34:27 +0000 (+0200) Subject: rust: auxiliary: move parent() to impl Device X-Git-Tag: v6.19-rc1~90^2~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b69165a09727b653993934d700a02d32a8961327;p=thirdparty%2Fkernel%2Flinux.git rust: auxiliary: move parent() to impl Device Currently, the parent method is implemented for any Device, i.e. any device context and returns a &device::Device. However, a subsequent patch will introduce impl Device { pub fn parent() -> device::Device { ... } } 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. Hence, move the current implementation. Reviewed-by: Alice Ryhl Reviewed-by: Greg Kroah-Hartman Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs index 8c0a2472c26ad..497601f7473bf 100644 --- a/rust/kernel/auxiliary.rs +++ b/rust/kernel/auxiliary.rs @@ -215,15 +215,15 @@ impl Device { // `struct auxiliary_device`. unsafe { (*self.as_raw()).id } } +} +impl Device { /// Returns a reference to the parent [`device::Device`]. pub fn parent(&self) -> &device::Device { // SAFETY: A `struct auxiliary_device` always has a parent. unsafe { self.as_ref().parent().unwrap_unchecked() } } -} -impl Device { extern "C" fn release(dev: *mut bindings::device) { // SAFETY: By the type invariant `self.0.as_raw` is a pointer to the `struct device` // embedded in `struct auxiliary_device`.