i2c_register_board_info(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ i2c_register_board_info(9) β€” the Kernel API Manual page you actually wanna read πŸ’…

okay so bestie, gather round, because this one is from the Kernel API Manual (section 9, kernel devs only, iykyk) and it's literally the function that lets you hard-code your I2C devices before anything else wakes up. no cap, it's iconic.


✨ NAME ✨

i2c_register_board_info β€” statically declare I2C devices πŸŽ€

like, you're writing down which devices exist ahead of time, on paper, before the kernel even knows what's up.


πŸ¦‹ SYNOPSIS πŸ¦‹

int i2c_register_board_info (int busnum , struct i2c_board_info const
       *info , unsigned len );

that's the whole signature, copy it exactly bestie, don't get creative 🫢


🌸 ARGUMENTS 🌸

  • busnum β€” identifies the bus to which these devices belong πŸ”₯ like which I2C bus these little guys are gonna live on.
  • info β€” vector of i2c device descriptors πŸ’– a whole array of "here's what this device is" structs.
  • len β€” how many descriptors in the vector; may be zero to reserve the specified bus number ⭐ yes, zero is legal, and it's giving "I'm just holding this bus number, don't touch it."

πŸ’œ DESCRIPTION πŸ’œ

so systems using the Linux I2C driver stack can declare tables of board info while they initialize πŸ‘‘ that's the whole vibe. This should be done in board-specific init code near arch_initcall time, or equivalent, and β€” listen β€” before any I2C adapter driver is registered. order matters bestie, fr fr.

for example, mainboard init code could define several devices, as could the init code for each daughtercard in a board stack πŸŽ€ everybody gets to declare their own little roster.

the I2C devices will be created later, after the adapter for the relevant bus has been registered. after that moment, standard driver model tools are used to bind "new style" I2C drivers to the devices. and here's the spicy part: the bus number for any device declared using this routine is not available for dynamic allocation 🌈 it's spoken for, periodt.

⚠️ also! the board info passed can safely be __initdata, but be careful of embedded pointers (for platform_data, functions, etc) since that won't be copied 😭 those pointers are on their own, so don't let them dangle into freed memory, okay?

πŸ” SEE ALSO πŸ”

  • Kernel file ./drivers/i2c/i2c-boardinfo.c β€” go read the source, it's right there 🧚

okay that's the whole page, slay πŸ’… this came out of ./drivers/i2c and it's dated October 2026 β€” mwah, bye bestie, go register some board info πŸ“πŸ’–βœ¨

πŸ“¦ where this page comes from