- Linux Device Driver Development Cookbook
- Rodolfo Giometti
- 205字
- 2021-06-24 13:54:13
How it works...
If we look carefully at the preceding printing functions (pr_info() and similar functions), we notice that they also depend on the pr_fmt(fmt) parameter, which can be used to add other useful information into our message. For instance, the following definition alters all messages generated by pr_info() by adding the current module and calling function names:
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
If we add this line to our dummy-code.c, as shown in the following code block, the kernel messages will change as described:
/*
* Dummy code
*/
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
#include <linux/module.h>
In fact, when the pr_info() function is executed the output message, telling us that the module has been inserted turns in the following form, where we can see the module name and the calling function name followed by the loading message:
dummy_code:dummy_code_init: dummy-code loaded
There is another set of printing functions but, before starting to talk about them, we need some information that is located in Chapter 3, Using the Device Tree, so, for the moment, we'll continue using these functions only.
- Learning OpenDaylight
- Windows Server 2012 Hyper-V:Deploying the Hyper-V Enterprise Server Virtualization Platform
- Mobile-first Bootstrap
- 構建可擴展分布式系統:方法與實踐
- 異質結原理與器件
- 嵌入式操作系統(Linux篇)(微課版)
- macOS效率手冊
- Dreamweaver CS5.5 Mobile and Web Development with HTML5,CSS3,and jQuery
- INSTANT Migration from Windows Server 2008 and 2008 R2 to 2012 How-to
- 一學就會:Windows Vista應用完全自學手冊
- Linux設備驅動開發
- Windows 10從新手到高手
- Linux 從入門到項目實踐(超值版)
- Linux內核API完全參考手冊(第2版)
- Windows Server 2008組網技術與實訓(第3版)