diff options
| author | Mark Brown <broonie@kernel.org> | 2026-07-01 13:58:54 +0100 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-07-01 13:58:54 +0100 |
| commit | 0143b1367dfcc22d1f786dfc3db7a8e7828d1887 (patch) | |
| tree | 9f97519b08bc99c4a5328e8ab4da9e26ac66ed58 | |
| parent | aa04dc3c32e1d9319ae1e2c49c9785f5b07e61ca (diff) | |
| parent | c0260c740d20751c8498865a9c5dc18b69c3d267 (diff) | |
| download | linux-next-0143b1367dfcc22d1f786dfc3db7a8e7828d1887.tar.gz linux-next-0143b1367dfcc22d1f786dfc3db7a8e7828d1887.zip | |
Merge branch 'rust-i2c-next' of https://github.com/ikrtn/rust-for-linux
| -rw-r--r-- | rust/kernel/i2c.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs index 624b971ca8b0..7655d61daac8 100644 --- a/rust/kernel/i2c.rs +++ b/rust/kernel/i2c.rs @@ -404,6 +404,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 @@ -425,11 +426,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()) } |
