STRUCT I2C_DRIVER(9)
π 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 inenum 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: thei2c_clientstructure which is handed to thedetectcallback is not a reali2c_client. it is initialized just enough so that you can calli2c_smbus_read_byte_dataand friends on it. don't do anything else with it. in particular, callingdev_dbgand friends on it is not allowed. fr fr, do not do it. π€
π SEE ALSO π
okay so go check out these icons π:
- 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_client(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)
that's the whole page, bestie π source: ./include/linux Β· date: October 2026 Β· manual: struct i2c_driver(9) β¨
π¦ 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