【发布时间】:2013-08-02 02:00:17
【问题描述】:
struct i2c_algorithm 具有用于 i2c 总线实现的 master_xfer 的函数指针模板。我在哪里可以找到linux内核源码中master_xfer的默认函数例程?
请有人指导我..
【问题讨论】:
标签: linux-kernel linux-device-driver
struct i2c_algorithm 具有用于 i2c 总线实现的 master_xfer 的函数指针模板。我在哪里可以找到linux内核源码中master_xfer的默认函数例程?
请有人指导我..
【问题讨论】:
标签: linux-kernel linux-device-driver
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.
*
【讨论】:
/driver/i2c/busses/ 中有 i2c-gpio.c 文件。我们用bit_xfer 填充master_xfer 函数。它确实有点敲击实现。
【讨论】: