module_exit源码分析

简介: module_exit源码分析

module_exit源码分析


上一章节我们讲述了module_init的源码分析及调用流程,本章节我们一块来看一下module_exit(x)这个函数。参考代码:linux/include/linux/module.h。

/**
 * module_exit() - driver exit entry point
 * @x: function to be run when driver is removed
 *
 * module_exit() will wrap the driver clean-up code
 * with cleanup_module() when used with rmmod when
 * the driver is a module.  If the driver is statically
 * compiled into the kernel, module_exit() has no effect.
 * There can only be one per module.
 */
#define module_exit(x)  __exitcall(x);

注释:当驱动程序是模块时,当与rmmod一起使用时,module_exit()将使用cleanup_module()包装驱动程序清理代码。如果驱动程序是静态编译到内核中的,则module_exit()不起作用。每个模块只能有一个。

我们继续看__exitcall(fn)的定义:

#define __exitcall(fn)            \
  static exitcall_t __exitcall_##fn __exit_call = fn

继续看exitcall_t的定义:

typedef void (*exitcall_t)(void);

它是一个函数指针,所指向的函数只有一个void类型的参数,返回类型为void。

相关文章
|
4天前
webpack 使用打包报错 ERROR in node_modules\@types\node\ts4.8\assert.d.ts
webpack 使用打包报错 ERROR in node_modules\@types\node\ts4.8\assert.d.ts
131 0
|
7月前
|
JavaScript Cloud Native Go
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
35 0
|
11月前
|
Java 关系型数据库 MySQL
8. 成功解决:Error: Module not specified
使用 IDEA 时,调用 `main` 方法,提示 `Error: Module not specified` 错误,意思是“module 未指定”。
1358 1
AttributeError: cannot assign module before Module.__init__() call 怎么解决?
这个错误通常是由于在__init__方法之外对模块中的某些成员进行了初始化或赋值操作,导致模块还没有被完全初始化就已经被调用了。为了解决这个问题,你需要将所有的初始化或赋值操作移到__init__方法内部。 例如,如果你有一个自定义模块MyModule,并且想要在其中定义一个类变量my_var,则应该将其放在__init__方法中:
508 0
|
JavaScript
Node:找不到模块Error: Cannot find module
Node:找不到模块Error: Cannot find module
75 0
|
Linux 编译器
module_init源码分析
module_init源码分析
|
Linux
原因及解决办法:Failed to load module “canberra-gtk-module“
原因及解决办法:Failed to load module “canberra-gtk-module“
444 0
|
Python
Python3 多线程问题:ModuleNotFoundError: No module named 'thread',原因及解决办法。
Python3 多线程问题:ModuleNotFoundError: No module named 'thread',原因及解决办法。
749 0
|
NoSQL Python
解决gdb报错:Failed to import the site module,No module named '_sysconfigdata_m'
解决gdb报错:Failed to import the site module,No module named '_sysconfigdata_m'
344 0
|
内存技术
Vite:Error: Cannot find module ‘worker_threads‘
Vite:Error: Cannot find module ‘worker_threads‘
546 0