summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-24 09:07:15 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-24 09:07:15 -0700
commit47096fc3d064a07c0842f748b99ebf01be120f2b (patch)
tree04a38725c9a2f18ef58c546b5af954a0fc116eb6 /rust
parentcf9610f9116d55c5a66ef9f1faecacabd93a9322 (diff)
parentd576a9561a1c80ae593539fb0ce0743d66825ac2 (diff)
Merge tag 'i2c-7.3-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux
Pull more i2c updates from Andi Shyti: "Fixes and cleanups around probe error handling, resource management and a minor Rust cleanup. Drivers: - several drivers: drop duplicate IRQ error reporting - imx-lpi2c: improve probe initialization and error cleanup - mxs: fix DMA channel leak on probe failure - ocores: fix clock cleanup on resume failure - rcar: handle reset controllers without status support Muxes: - demux-pinctrl: fix OF node leak on allocation failure Rust: - mark trivial I2cAdapter reference-counting methods inline" * tag 'i2c-7.3-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux: i2c: rust: mark I2cAdapter methods as inline i2c: rcar: fix reset handling for Gen5 i2c: mxs: fix DMA channel leak on probe error i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure i2c: ocores: Disable clock on failed resume i2c: imx-lpi2c: reset controller in probe stage i2c: imx-lpi2c: properly unwind resources on probe failure i2c: busses: drop redundant dev_err_probe() around irq helpers
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 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()) }