码迷,mamicode.com
首页 > 其他好文 > 详细

__devexit_p的功能

时间:2015-07-24 17:34:22      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

看驱动的时候,时常会有如下代码:
.remove = __devexit_p(XX_exit),

这里的__devexit_p有什么作用呢?
我在include/linux/init.h中找到了它的定义:

/* 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

 

编译成模块或有热拔插功能时, 就需要exit函数。 否则可以为NULL, 节约空间

__devexit_p的功能

标签:

原文地址:http://www.cnblogs.com/cute/p/4673981.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!