struct i2c_algorithm
具有master_xfer
的函数指针模板,用于i2c总线实现。在哪里可以找到linux内核源代码中master_xfer
的默认函数例程。
请有人指导我..
答案 0 :(得分:1)
master_xfer的设置取决于您的平台和总线。在drivers / i2c / busses /下查找此函数指针的设置位置。请注意,它可以设置为NULL。
设置位置的示例在drivers / i2c / busses / i2c-pxa.c中:
static const struct i2c_algorithm i2c_pxa_algorithm = {
.master_xfer = i2c_pxa_xfer,
.functionality = i2c_pxa_functionality,
};
另请参阅include / linux / i2c.h:
struct i2c_algorithm {
/* If an adapter algorithm can't do I2C-level access, set master_xfer
to NULL. If an adapter algorithm can do SMBus access, set
smbus_xfer. If set to NULL, the SMBus protocol is simulated
using common I2C messages */
/* master_xfer should return the number of messages successfully
processed, or a negative value on error */
int (*master_xfer)(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);
/* To determine what the adapter supports */
u32 (*functionality) (struct i2c_adapter *);
};
* An i2c_msg is the low level representation of one segment of an I2C
* transaction. It is visible to drivers in the @i2c_transfer() procedure,
* to userspace from i2c-dev, and to I2C adapter drivers through the
* @i2c_adapter.@master_xfer() method.
*
答案 1 :(得分:0)
/ driver / i2c / busses /中有i2c-gpio.c文件。我们正在使用master_xfer
填充bit_xfer
函数。它确实有点猛烈的实施。