有人可以告诉我__devexit_p
部分驱动程序文件的用途吗?
我发现__devexit_p
通常与驱动程序代码中的删除功能一起使用
示例1 :
static struct i2c_driver lsm9ds0_driver = {
.driver = {
.owner = THIS_MODULE,
.name = LSM9DS0_DEV_NAME,
},
.probe = lsm9ds0_probe,
.remove = __devexit_p(lsm9ds0_remove),
.id_table = lsm9ds0_id,
};
示例2:
static struct spi_driver light_driver = {
.driver = {
.name = "light",
.owner = THIS_MODULE,
},
.probe = light_probe,
.remove = __devexit_p(light_remove),
};
如果我从上面的示例中删除了__devexit_p
,会有什么不同吗?
移除__devexit_p
后会影响驱动程序的性能吗?
答案 0 :(得分:4)
/*
Functions marked as __devexit may be discarded at kernel link time,
depending on config options. Newer versions of binutils detect references
from retained sections to discarded sections and flag an error. Pointers to
__devexit functions must use __devexit_p(function_name), the wrapper will
insert either the function_name or NULL, depending on the config options.
*/
#if defined(MODULE) || defined(CONFIG_HOTPLUG)
#define __devexit_p(x) x
#else
#define __devexit_p(x) NULL
#endif
似乎用于根据作为内核模块(NULL
)和MODULE
内核的一部分编译的代码,有条件地将其扩展为给定参数或CONFIG_HOTPLUG
选项。