STRUCT I2C_DRIVER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

welcome to the struct i2c_driver(9) page from the Kernel API Manual, bestie πŸ’–

struct i2c_driver β€” represent an I2C device driver ✨


✨ SYNOPSIS ✨

okay so here's the exact struct, no cap:

struct i2c_driver {
    unsigned int class;
    int (*probe)(struct i2c_client *client);
    void (*remove)(struct i2c_client *client);
    void (*shutdown)(struct i2c_client *client);
    void (*alert)(struct i2c_client *client, enum i2c_alert_protocol
protocol, unsigned int data);
    int (*command)(struct i2c_client *client, unsigned int cmd, void
*arg);
    struct device_driver driver;
    const struct i2c_device_id *id_table;
    int (*detect)(struct i2c_client *client, struct i2c_board_info
*info);
    const unsigned short *address_list;
    struct list_head clients;
    u32 flags;
 };

πŸ’… Members πŸ’…

  • class β€” what kind of i2c device we instantiate (for detect) πŸŽ€
  • probe β€” callback for device binding 🫢
  • remove β€” callback for device unbinding 😭
  • shutdown β€” callback for device shutdown πŸ’€
  • alert β€” alert callback, for example for the SMBus alert protocol πŸ””
  • command β€” callback for bus-wide signaling (optional) β€” lowkey optional, highkey useful ✨
  • driver β€” device driver model driver πŸ‘‘
  • id_table β€” list of I2C devices supported by this driver 🌸
  • detect β€” callback for device detection πŸ•΅οΈβ€β™€οΈ
  • address_list β€” the I2C addresses to probe (for detect) πŸ“
  • clients β€” list of detected clients we created (for i2c-core use only) β€” bestie do not touch, i2c-core use only πŸ”’
  • flags β€” a bitmask of flags defined in enum i2c_driver_flags 🚩

πŸ”₯ Description πŸ”₯

okay so first things first: the driver.owner field should be set to the module owner of this driver. and the driver.name field should be set to the name of this driver. periodt. πŸ’…

for automatic device detection, both detect and address_list must be defined. class should also be set, otherwise only devices forced with module parameters will be created. the detect function must fill at least the name field of the i2c_board_info structure it is handed upon successful detection, and possibly also the flags field. πŸ¦‹

if detect is missing, the driver will still work fine for enumerated devices. detected devices simply won't be supported. this is expected for the many I2C/SMBus devices which can't be detected reliably, and the ones which can always be enumerated in practice. no cap. ✨

⚠️ bestie listen: the i2c_client structure which is handed to the detect callback is not a real i2c_client. it is initialized just enough so that you can call i2c_smbus_read_byte_data and friends on it. don't do anything else with it. in particular, calling dev_dbg and friends on it is not allowed. fr fr, do not do it. 😀

🌈 SEE ALSO 🌈

okay so go check out these icons πŸ‘‘:


that's the whole page, bestie πŸ’– source: ./include/linux Β· date: October 2026 Β· manual: struct i2c_driver(9) ✨

πŸ“¦ where this page comes from