summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-08-21 13:56:55 +0100
committerMark Brown <broonie@kernel.org>2026-08-21 13:56:55 +0100
commitbcb73257a64551021250fa9da8a160f07df7c989 (patch)
tree66d4d6b1d90cf9534772d2b2de7079b043e2f172
parent777931af6e53b13544d4993e653b182c35ae2c62 (diff)
parent61ddec70c9bcc3d4b0471c8683e57d3b03cecf0a (diff)
downloadlinux-next-bcb73257a64551021250fa9da8a160f07df7c989.tar.gz
linux-next-bcb73257a64551021250fa9da8a160f07df7c989.zip
Merge branch 'rust-i2c-next' of https://github.com/ikrtn/rust-for-linux
-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 fbc5fb06ca16..0487bae811fb 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()) }