linux驱动常用函数头文件

1、#include <linux/module.h>

#define module_init(x) ...
#define module_exit(x) ...
#define MODULE_LICENSE(_license) ...
#define MODULE_AUTHOR(_author) ...
#define MODULE_DESCRIPTION(_description) ...
#define MODULE_VERSION(_version) ...
  • 例:
static int __init test_init(void)
{
  return 0;
}

static void __exit test_exit(void)
{
  ...
}

module_init(test_init);
module_exit(test_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Test driver");
MODULE_AUTHOR("Huang Xing");
MODULE_VERSION("1.0");

2、#include <linux/moduleparam.h>

#define module_param(name, type, perm) ...
#define module_param_named(name, value, type, perm) ...
  • 例:
module_param(g_test_var, int, 0644);
module_param_named(var, g_test_var, int, 0644);

3、#include <linux/printk.h>

int printk(const char *fmt, ...);
#define pr_info(fmt, ...) ...
#define pr_warn(fmt, ...) ...
#define pr_err(fmt, ...)
posted @ 2020-12-18 20:35  hug567  阅读(473)  评论(0)    收藏  举报