哪里可以找到i2c“master_xfer”函数的一般定义?

时间:2013-08-01 17:25:29

标签: linux-kernel linux-device-driver

struct i2c_algorithm具有master_xfer的函数指针模板,用于i2c总线实现。在哪里可以找到linux内核源代码中master_xfer的默认函数例程。 请有人指导我..

2 个答案:

答案 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函数。它确实有点猛烈的实施。