__devexit_p的功能

__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。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章