首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >驱动程序文件中__devexit_p的用途

驱动程序文件中__devexit_p的用途
EN

Stack Overflow用户
提问于 2015-07-28 10:12:28
回答 1查看 1.5K关注 0票数 5

有人能告诉我驱动程序文件中__devexit_p部件的用途吗?

我发现__devexit_p通常在驱动程序代码中使用删除函数。

示例1

代码语言:javascript
复制
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:

代码语言:javascript
复制
static struct spi_driver light_driver = {
    .driver = {
        .name = "light",
        .owner = THIS_MODULE,
    },
    .probe = light_probe,
    .remove = __devexit_p(light_remove),
};

如果我从上面的例子中删除了__devexit_p,会有什么不同吗?当__devexit_p删除时,它会影响驱动程序的性能吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-28 10:51:06

基于这个2.6.32中的LXR列表

代码语言:javascript
复制
/*
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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31673341

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档