Linux kernel 在哪里可以找到i2c的一般定义;大师“xfer”;功能?

Linux kernel 在哪里可以找到i2c的一般定义;大师“xfer”;功能?,linux-kernel,linux-device-driver,Linux Kernel,Linux Device Driver,struct i2c_算法具有用于i2c总线实现的master_xfer的函数指针模板。在linux内核源代码中,哪里可以找到master\u xfer的默认函数例程。? 请有人指导我。master\u xfer的设置取决于您的平台和总线。在drivers/i2c/busses/下查找此函数指针的设置位置。请注意,可以将其设置为NULL 在驱动器/i2c/busses/i2c pxa.c中设置它的示例: static const struct i2c_algorithm i2c_pxa_algo

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

master\u xfer的设置取决于您的平台和总线。在drivers/i2c/busses/下查找此函数指针的设置位置。请注意,可以将其设置为NULL

在驱动器/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 *);
};
:


master_xfer的设置取决于您的平台和总线。在drivers/i2c/busses/下查找此函数指针的设置位置。请注意,可以将其设置为NULL

在驱动器/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 *);
};
:


在/driver/i2c/busses/中有i2c gpio.c文件。在这一点上,我们用
bit\u xfer
填充
master\u xfer
函数。它执行位碰撞实现。

在/driver/i2c/busses/中有i2c gpio.c文件。在这一点上,我们用
bit\u xfer
填充
master\u xfer
函数。它的实现非常出色。

感谢您的澄清。。很有用。。。但是,假设我使用的是I2c gpio,请参考哪里。@kzs它看起来像是位碰撞I2c gpio接口只使用I2c_适配器结构,而不是I2c_算法。不,Peter,实际上它使用的是I2c gpio.c,在同一路径中。在这里,我们用位\u xfer填充主\u xfer函数。谢谢你的参考。谢谢你的澄清。。很有用。。。但是,假设我使用的是I2c gpio,请参考哪里。@kzs它看起来像是位碰撞I2c gpio接口只使用I2c_适配器结构,而不是I2c_算法。不,Peter,实际上它使用的是I2c gpio.c,在同一路径中。在这里,我们用位\u xfer填充主\u xfer函数。谢谢你的推荐。