aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
authorNicolás Antinori <nico.antinori.7@gmail.com>2026-05-21 16:08:50 -0300
committerIgor Korotin <igor.korotin@linux.dev>2026-05-24 13:19:06 +0100
commitc0260c740d20751c8498865a9c5dc18b69c3d267 (patch)
tree46c77869cd205e4a52f0d94b32e6fb6949164157 /rust
parent254f49634ee16a731174d2ae34bc50bd5f45e731 (diff)
downloadlinux-next-history-c0260c740d20751c8498865a9c5dc18b69c3d267.tar.gz
i2c: rust: mark I2cAdapter methods as inline
When building the kernel using llvm-19.1.7-rust-1.85.0-x86_64, the following symbols are generated: $ nm vmlinux | grep ' _R'.*I2cAdapter | rustfilt ffffffff817ff380 T <kernel::i2c::I2cAdapter>::get ffffffff817ff400 T <kernel::i2c::I2cAdapter as kernel::sync::aref::AlwaysRefCounted>::dec_ref ffffffff817ff3e0 T <kernel::i2c::I2cAdapter as kernel::sync::aref::AlwaysRefCounted>::inc_ref However, these Rust symbols are trivial wrappers around the `i2c_get_adapter` and `i2c_put_adapter` functions. It doesn't make sense to go through a trivial wrapper for these functions. Link: https://github.com/Rust-for-Linux/linux/issues/1145 Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com> Reviewed-by: Onur Özkan <work@onurozkan.dev> Reviewed-by: Igor Korotin <igor.korotin@linux.dev> Signed-off-by: Igor Korotin <igor.korotin@linux.dev>
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/i2c.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs
index 7b908f0c5a58d..07f9fd53c4e50 100644
--- a/rust/kernel/i2c.rs
+++ b/rust/kernel/i2c.rs
@@ -397,6 +397,7 @@ impl I2cAdapter {
}
/// Gets pointer to an `i2c_adapter` by index.
+ #[inline]
pub fn get(index: i32) -> Result<ARef<Self>> {
// SAFETY: `index` must refer to a valid I2C adapter; the kernel
// guarantees that `i2c_get_adapter(index)` returns either a valid
@@ -416,11 +417,13 @@ kernel::impl_device_context_into_aref!(I2cAdapter);
// SAFETY: Instances of `I2cAdapter` are always reference-counted.
unsafe impl AlwaysRefCounted for I2cAdapter {
+ #[inline]
fn inc_ref(&self) {
// SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
unsafe { bindings::i2c_get_adapter(self.index()) };
}
+ #[inline]
unsafe fn dec_ref(obj: NonNull<Self>) {
// SAFETY: The safety requirements guarantee that the refcount is non-zero.
unsafe { bindings::i2c_put_adapter(obj.as_ref().as_raw()) }