i2c_trylock_bus(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… i2c_trylock_bus(9) β€” bestie, this is from the Kernel API Manual

Okay so picture this: you're deep in the kernel, you've got an I2C bus segment, and you want exclusive access to it β€” but like, only if it's free. You are not about to wait around. This is i2c_trylock_bus(9), and it's giving "try before you commit" energy. πŸŽ€


✨ SYNOPSIS ✨

int i2c_trylock_bus (struct i2c_adapter *adapter , unsigned int flags );

Two things go in, one int comes out. Simple. Iconic. πŸ¦‹


🌸 ARGUMENTS 🌸

  • adapter β€” the target I2C bus segment. Like, the actual bus you're trying to claim. Point at it and go πŸ’…
  • flags β€” this is where you pick your vibe:
    • I2C_LOCK_ROOT_ADAPTER tries to lock the root i2c adapter (yes, the whole top-level situation πŸ‘‘)
    • I2C_LOCK_SEGMENT tries to lock only this branch in the adapter tree 🌿 β€” very "just this one, not the whole family" of it

⭐ RETURN ⭐

Returns true if the I2C bus segment is locked, false otherwise. That's it. No drama, just a yes or a no. 🫢

Heads up bestie: the page says true / false, but the function signature is int β€” I'm just reporting what the manual says, no cap. πŸ™ˆ

πŸ’– SEE ALSO πŸ’–

The kernel file ./include/linux/i2c.h, plus the whole friend group:

Like, literally the entire I2C cinematic universe. 🌈


And that's the whole page, bestie β€” sourced from ./include/linux, dated October 2026, filed under i2c_trylock_bus(9). Go lock that bus (or don't, it's a try). Periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from