STRUCT I2C_ALGORITHM(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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} β€” anonymous
  • xfer β€” Transfer a given number of messages defined by the msgs array via the specified adapter.
  • master_xfer β€” deprecated, use xfer
  • {unnamed_union} β€” anonymous
  • xfer_atomic β€” Same as xfer. Yet, only using atomic context so e.g. PMICs can be accessed very late before shutdown. Optional.
  • master_xfer_atomic β€” deprecated, use xfer_atomic
  • smbus_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 as smbus_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 the I2C_FUNC_* flags.
  • {unnamed_union} β€” anonymous
  • reg_target β€” Register given client to local target mode of this adapter
  • reg_slave β€” deprecated, use reg_target
  • {unnamed_union} β€” anonymous
  • unreg_target β€” Unregister given client from local target mode of this adapter
  • unreg_slave β€” deprecated, use unreg_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:


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