rust: pci: Mark Device refcount methods inline
PATCH 1/1 rust: pci: Mark Device refcount methods inline
When building the kernel, the following Rust symbols are generated:
$ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)' ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
These Rust symbols are trivial wrappers around pci_dev_put() and pci_dev_get(), respectively. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline.
--- rust/kernel/pci.rs | 2 ++ 1 file changed, 2 insertions(+)
rust/kernel/pci.rs +2 -0
@@ -482,11 +482,13 @@ impl<'a> crate::dma::Device<'a> for Device<device::Core<'a>> {}// SAFETY: Instances of `Device` are always reference-counted. unsafe impl crate ::sync::aref::AlwaysRefCounted for Device { +#[inline] fn inc_ref (&self) {// SAFETY: The existence of a shared reference guarantees that the refcount is non-zero. unsafe { bindings::pci_dev_get (self.as_raw ()) }; } +#[inline] unsafe fn dec_ref (obj:NonNull <Self >) {// SAFETY: The safety requirements guarantee that the refcount is non-zero. unsafe { bindings::pci_dev_put (obj.cast ().as_ptr ()) }
---
base-commit: dc01dfb37b34beeefcfe1c3055364d41a4070c7e
change-id: 20260804-inline-wrappers-f869b6e4601e
Best regards,
Signature · 1 line
Ethan Plant <[email protected]>
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
From: Ethan Plant <[email protected]>
When building the kernel, the following Rust symbols are generated:
$ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)' ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
Quoted 7 lines
These Rust symbols are trivial wrappers around
pci_dev_put()andpci_dev_get(), respectively. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline.Suggested-by Alice Ryhl <[email protected]>Signed-off-by Ethan Plant <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 8 lines · On Wed, Aug 5, 2026 at 1:24 AM Ethan Plant via B4 Relay…
From: Ethan Plant <[email protected]>
When building the kernel, the following Rust symbols are generated:
$ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)' ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
Quoted 7 lines
These Rust symbols are trivial wrappers around
pci_dev_put()andpci_dev_get(), respectively. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline.Suggested-by Alice Ryhl <[email protected]>Signed-off-by Ethan Plant <[email protected]>
Quoted 1 line · Ethan Plant
[PATCH] rust: pci: Mark Device refcount methods inline
Applied, thanks!
Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] rust: pci: Mark Device refcount methods inline
commit: 56c193a5cb37
The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).
The patch is in the driver-core-testing branch and will be promoted to driver-core-next after validation.