devm_i2c_add_adapter(9)
π devm_i2c_add_adapter(9) β from the Kernel API Manual, bestie
okay so picture this: you're deep in kernel land, the Kernel API Manual is open (yes we're fancy, that's the manual name, write it down), and you need an I2C adapter that cleans up after itself. That's literally this function. Main character energy only. π
β¨ NAME β¨
devm_i2c_add_adapter β the device-managed variant of i2c_add_adapter(). That's the whole vibe. Devm does the chores so you don't have to. π§
β¨ SYNOPSIS β¨
int devm_i2c_add_adapter (struct device *dev , struct i2c_adapter
*adapter );
β¨ ARGUMENTS β¨
devβ the managing device for adding this I2C adapter. it's the one holding the leash π«Άadapterβ the adapter to add. yes, this one. the actual adapter π
β¨ CONTEXT β¨
can sleep π΄ β so don't you dare call it from somewhere you can't, no cap.
β¨ DESCRIPTION β¨
So what it does: adds the adapter with a dynamic bus number, exactly the same as i2c_add_adapter, except β and this is the iconic part β the adapter gets auto deleted on driver detach. The kernel handles the breakup for you, so you never have to sit there manually cleaning up. genuinely obsessed. πΈ
β¨ SEE ALSO β¨
Kernel file ./drivers/i2c/i2c-core-base.c β go read it, it's giving lore. π
And the whole friend group, in order, don't skip anyone:
i2c_verify_client(9), i2c_adapter_lock_bus(9), i2c_adapter_trylock_bus(9), i2c_adapter_unlock_bus(9), i2c_new_client_device(9), i2c_unregister_device(9), i2c_find_device_by_fwnode(9), i2c_new_dummy_device(9), devm_i2c_new_dummy_device(9), i2c_new_ancillary_device(9), i2c_verify_adapter(9), i2c_handle_smbus_host_notify(9), i2c_add_adapter(9), i2c_add_numbered_adapter(9), i2c_del_adapter(9), i2c_find_adapter_by_fwnode(9), i2c_get_adapter_by_fwnode(9), i2c_parse_fw_timings(9), i2c_del_driver(9), __i2c_transfer(9), i2c_transfer(9), i2c_transfer_buffer_flags(9), i2c_get_device_id(9), i2c_client_get_device_id(9), i2c_get_dma_safe_msg_buf(9), i2c_put_dma_safe_msg_buf(9)
lowkey reminder: i2c_add_adapter gives you the plain version, this one gives you the version where the kernel remembers to clean up. pick your fighter π
and that's the page!! source lives in ./drivers/i2c, dated October 2026, and the whole thing is filed under devm_i2c_add_adapter(9) in the Kernel API Manual. slay, go write a driver, ily bye π¦πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms