linux内核 dev_info函数解析

内核中的 dev_emerg/dev_alert/dev_crit/dev_err/dev_warn/dev_notice/_dev_info_adaptiver的博客-CSDN博客

使用:

Linux内核中dev_info、dev_dbg、dev_err及动态调试_轩阁楼主的博客-CSDN博客_dev_info linux

笔记:

1、mount命令查看debugfs文件系统是否被挂载

2、dev_info,dev_err信息可以直接在串口中打印出来;

     dev_dbg查看打印信息:

      a、echo -n "file xxx.c +p" > control

      b、dmesg(只能在这里面看到,dmesg打印从内核开始到现在为止的所有内核打印信息)

3、测试程序:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

struct task_struct *dbg_task;
struct platform_device* pdev;

static int dbg_thread(void *data)
{
	while (!kthread_should_stop())
    {
    	dev_dbg(NULL,"songhp dbg print test\n");
    	mdelay(2000);
	}
	
	return 0;
}

static int __init printk_test_init(void)
{
	
	dev_info(NULL,"songhp info print test\n");
	
	dbg_task = kthread_run(dbg_thread, NULL, "dbg_t");

	dev_err(NULL,"songhp err print test\n");
	
	return 0;
}

static void __exit printk_test_exit(void)
{
	return;
}

module_init(printk_test_init);
module_exit(printk_test_exit);

你可能感兴趣的:(linux)