i2c_check_functionality函数的实现

来源:互联网 发布:淘大象软件下载 编辑:程序博客网 时间:2024/06/16 01:03

下面再来讨论下前面一章中i2c_probe函数中调用的i2c_check_functionality函数的实现。

I2c_probe函数中有这样一段:

       /* Stop here if we can't use SMBUS_QUICK */

       if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {

              if (address_data->probe[0] == I2C_CLIENT_END

               && address_data->normal_i2c[0] == I2C_CLIENT_END)

                    return 0;

 

              dev_warn(&adapter->dev, "SMBus Quick command not supported, "

                      "can't probe for chips\n");

              return -1;

       }

追踪i2c_check_functionality

static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)

{

       return (func & i2c_get_functionality(adap)) == func;

}

static inline u32 i2c_get_functionality(struct i2c_adapter *adap)

{

       return adap->algo->functionality(adap);

}

可见还是调用了algothmfunctionlity函数。

我们来看看该驱动中这个函数的实现:

static struct i2c_algorithm mxc_i2c_algorithm = {

       .master_xfer = mxc_i2c_xfer,

       .functionality = mxc_i2c_func

};

static u32 mxc_i2c_func(struct i2c_adapter *adap)

{

       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;

}

 

可见就是要该适配器支持I2C_FUNC_SMBUS_QUICK的功能。


头文件中I2C_FUNC_I2C和I2C_FUNC_SMBUS_QUICK的定义

I2C_FUNC_I2C                    Plain i2c-level commands (Pure SMBus                                  adapters typically can not do these)
I2C_FUNC_SMBUS_QUICK            Handles the SMBus write_quick command



0 0
原创粉丝点击