STRUCT I2C_CLIENT(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 struct i2c_client(9) 🌸

okay so bestie, welcome to the Kernel API Manual πŸ’– this one's about struct i2c_client and it's genuinely not that deep, i promise. it's just... the little ID card for one single chip on an i2c bus. slay.


✨ NAME ✨

struct i2c_client β€” represent an I2C slave device πŸŽ€

like, literally, that's the whole vibe. it's the representation. the moment. the struct.


🌈 SYNOPSIS 🌈

okay here's the whole thing, verbatim, don't @ me:

struct i2c_client {
    unsigned short flags;
  #define I2C_CLIENT_PEC          0x04    ;
  #define I2C_CLIENT_TEN          0x10    ;
  #define I2C_CLIENT_SLAVE        0x20    ;
  #define I2C_CLIENT_HOST_NOTIFY  0x40    ;
  #define I2C_CLIENT_WAKE         0x80    ;
  #define I2C_CLIENT_SCCB         0x9000  ;
    unsigned short addr;
    char name[I2C_NAME_SIZE];
    struct i2c_adapter *adapter;
    struct device dev;
    int init_irq;
    int irq;
    struct list_head detected;
  #if IS_ENABLED(CONFIG_I2C_SLAVE);
    i2c_slave_cb_t slave_cb;
  #endif;
    void *devres_group_id;
    struct dentry *debugfs;
 };

look at her. gorgeous. no notes. πŸ‘‘


πŸ¦‹ Members πŸ¦‹

okay so let's go field by field, group-chat style. every single one, no skipping, i would never πŸ™ˆ

  • flags β€” the I2C_CLIENT_* defines are where the actual possibilities live, so go check those out. literally "see I2C_CLIENT_* for possible flags". that's the assignment bestie πŸ’…
  • addr β€” the address used on the I2C bus that's connected to the parent adapter. that's the address, that's it, that's the whole field ✨
  • name β€” it tells you the type of the device. usually it's a chip name picked to be generic enough to hide second-sourcing and compatible revisions πŸ‘€ so like, the name is doing PR work for the silicon. iconic honestly.
  • adapter β€” this one manages the bus segment that's hosting this I2C device. the adapter runs the block, this client just lives there 🏠
  • dev β€” the driver model device node for the slave. your driver-model paperwork, basically πŸŽ€
  • init_irq β€” the IRQ that was set at initialization. the original one. the one from the beginning ⭐
  • irq β€” indicates the IRQ generated by this device, if any. note the "if any" β€” some devices are just out here with no interrupts at all and that's valid πŸ’€
  • detected β€” this member is either part of a i2c_driver.clients list, or part of i2c-core's userspace_devices list. it's a list member, she's social 🌸
  • slave_cb β€” the callback used when the adapter's I2C slave mode is in play. the adapter calls it to pass slave events along to the slave driver. also she's wrapped in #if IS_ENABLED(CONFIG_I2C_SLAVE) so if that's not enabled she's simply not invited 🫢
  • devres_group_id β€” the id of the devres group that's gonna get created for the resources acquired when probing this device. it's giving resource management ✨
  • debugfs β€” pointer to the debugfs subdirectory that the I2C core created for this client. cute little debug home 🏑

πŸ’œ Description πŸ’œ

okay so the actual plot: an i2c_client identifies one single device (read: chip) that's connected to an i2c bus. that's the job. one chip, one client.

and the behaviour that Linux actually gets to see? that's defined by the driver managing the device. so like, the struct is the ID card, the driver is the personality πŸ˜­πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

the friend group, in full, no cuts:

Kernel file ./include/linux/i2c.h, i2c_master_recv(9), i2c_master_recv_dmasafe(9), i2c_master_send(9), i2c_master_send_dmasafe(9), struct i2c_device_identity(9), enum i2c_driver_flags(9), struct i2c_driver(9), struct i2c_board_info(9), I2C_BOARD_INFO(9), struct i2c_algorithm(9), struct i2c_lock_operations(9), struct i2c_timings(9), struct i2c_bus_recovery_info(9), struct i2c_adapter_quirks(9), i2c_lock_bus(9), i2c_trylock_bus(9), i2c_unlock_bus(9), i2c_mark_adapter_suspended(9), i2c_mark_adapter_resumed(9), i2c_check_quirks(9), module_i2c_driver(9), builtin_i2c_driver(9)


ok that's the whole page bestie, go build something, i believe in you πŸ’–

and that's a wrap πŸŽ€ this came out of ./include/linux, dated October 2026, for struct i2c_client(9) β€” mwah, bye βœ¨πŸ’…

πŸ“¦ where this page comes from