__devexit_p的功能

__devexit_p是在Linux内核中用于标记可以在链接时被丢弃的设备退出函数的一个宏。该宏根据内核配置选项返回函数地址或NULL,确保在不支持模块和热插拔的环境中函数不会被误引用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

__devexit_p的功能

在看i2c驱动的时候,看到有如下代码:
.remove     = __devexit_p(i2c_gpio_remove),

这里的__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

 

意义是内核可能在不支持模块且不支持热插拔的时候,需要对 __devexit_p返回NULL。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值