STRUCT I2C_ALGORITHM(9)
okay so this is the struct i2c_algorithm(9) page from the Kernel API Manual, and bestie it is literally the blueprint for I2C transfer methods πβ¨
π NAME π
struct i2c_algorithm β represent I2C transfer methods π«Ά
β¨ SYNOPSIS β¨
struct i2c_algorithm {
union {
int (*xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int
num);
int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num);
};
union {
int (*xfer_atomic)(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num);
int (*master_xfer_atomic)(struct i2c_adapter *adap, struct i2c_msg
*msgs, int num);
};
int (*smbus_xfer)(struct i2c_adapter *adap, u16 addr, unsigned short
flags, char read_write, u8 command, int size, union i2c_smbus_data
*data);
int (*smbus_xfer_atomic)(struct i2c_adapter *adap, u16 addr,
unsigned short flags, char read_write, u8 command, int size, union
i2c_smbus_data *data);
u32 (*functionality)(struct i2c_adapter *adap);
#if IS_ENABLED(CONFIG_I2C_SLAVE);
union {
int (*reg_target)(struct i2c_client *client);
int (*reg_slave)(struct i2c_client *client);
};
union {
int (*unreg_target)(struct i2c_client *client);
int (*unreg_slave)(struct i2c_client *client);
};
#endif;
};
π Members π
okay so here's the member-by-member vibe check, bestie π
{unnamed_union}β anonymousxferβ Transfer a given number of messages defined by themsgsarray via the specified adapter.master_xferβ deprecated, usexfer{unnamed_union}β anonymousxfer_atomicβ Same asxfer. Yet, only using atomic context so e.g. PMICs can be accessed very late before shutdown. Optional.master_xfer_atomicβ deprecated, usexfer_atomicsmbus_xferβ Issue SMBus transactions to the given I2C adapter. If this is not present, then the bus layer will try and convert the SMBus calls into I2C transfers instead.smbus_xfer_atomicβ Same assmbus_xfer. Yet, only using atomic context so e.g. PMICs can be accessed very late before shutdown. Optional.functionalityβ Return the flags that this algorithm/adapter pair supports from theI2C_FUNC_*flags.{unnamed_union}β anonymousreg_targetβ Register given client to local target mode of this adapterreg_slaveβ deprecated, usereg_target{unnamed_union}β anonymousunreg_targetβ Unregister given client from local target mode of this adapterunreg_slaveβ deprecated, useunreg_target
πΈ Description πΈ
okay so i2c_algorithm is the interface to a class of hardware solutions which can be addressed using the same bus algorithms β i.e. bit-banging or the PCF8584 to name two of the most common. No cap. π§
The return codes from the xfer{_atomic} fields should indicate the type of error code that occurred during the transfer, as documented in the Kernel Documentation file Documentation/i2c/fault-codes.rst. Otherwise, the number of messages executed should be returned. π
π₯ SEE ALSO π₯
Kernel file: ./include/linux/i2c.h. Also, the bestie reading list is iconic:
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_client(9)struct i2c_board_info(9)I2C_BOARD_INFO(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)
okay that's the whole page, bestie π«Ά it comes from ./include/linux, dated October 2026, and the title is struct i2c_algorithm(9) β periodt π
π
π¦ 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