summaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
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 fbc5fb06c..0487bae81 100644
--- a/rust/kernel/i2c.rs
+++ b/rust/kernel/i2c.rs
@@ -394,6 +394,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
@@ -415,11 +416,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()) }