1
0
mirror of https://github.com/bashrc/LKMPG.git synced 2018-06-11 03:06:54 +02:00
This commit is contained in:
Bob Mottram
2017-07-12 17:54:24 +01:00
parent 84f3879c86
commit cf687bc069
2 changed files with 283 additions and 283 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -216,7 +216,7 @@ Typically, init_module() either registers a handler for something with the kerne
Lastly, every kernel module needs to include linux/module.h. We needed to include *linux/kernel.h* only for the macro expansion for the printk() log level, KERN_ALERT, which you'll learn about in Section 2.1.1.
**** A point about coding style
Another thing which may not be immediately obvious to anyone getting started with kernel programming is that indentation within your code should be using *tabs* and *not spaces*. It's one of the coding conventions of the kernel, and you'll need to get used to it if you ever submit a patch upstream.
Another thing which may not be immediately obvious to anyone getting started with kernel programming is that indentation within your code should be using *tabs* and *not spaces*. It's one of the coding conventions of the kernel. You may not like it, but you'll need to get used to it if you ever submit a patch upstream.
**** Introducing printk()
Despite what you might think, *printk()* was not meant to communicate information to the user, even though we used it for exactly this purpose in hello-1! It happens to be a logging mechanism for the kernel, and is used to log information or give warnings. Therefore, each printk() statement comes with a priority, which is the <1> and KERN_ALERT you see. There are 8 priorities and the kernel has macros for them, so you don't have to use cryptic numbers, and you can view them (and their meanings) in *linux/kernel.h*. If you don't specify a priority level, the default priority, DEFAULT_MESSAGE_LOGLEVEL, will be used.