有人能告诉我驱动程序文件中__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删除时,它会影响驱动程序的性能吗?
发布于 2015-07-28 10:51:06
基于这个2.6.32中的LXR列表
/*
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它似乎被用于根据作为内核模块(MODULE)的一部分编译的代码和CONFIG_HOTPLUG内核选项,有条件地将其扩展到给定的参数或CONFIG_HOTPLUG。
https://stackoverflow.com/questions/31673341
复制相似问题