Accessing the client
Serial bus transactions are just a matter of accessing registers to set/get their content. I2C respects that principle. I2C core provides two kinds of API, one for plain I2C communications and another for SMBUS-compatible devices, which also works with I2C devices but not the reverse.
Plain I2C communication
The following are essential functions you usually deal with when talking to I2C devices:
int i2c_master_send(struct i2c_client *client, const char *buf, int count); int i2c_master_recv(struct i2c_client *client, char *buf, int count);
Almost all I2C communication functions take a struct i2c_client
as the first parameter. The second parameter contains the bytes to read or write and the third represents the number of bytes to read or write. Like any read/write function, the returned value is the number of bytes being read/written. You can also process message transfers with:
int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg,int num);
i2c_transfer
sends a...