Skip to content

Commit b8bbcd8

Browse files
committed
treewide: Replace kernel.h by printk.h
The kernel.h should be discouraged for use. Signed-off-by: Andy Shevchenko <[email protected]>
1 parent e62dff0 commit b8bbcd8

15 files changed

+18
-15
lines changed

examples/bottomhalf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <linux/delay.h>
1212
#include <linux/gpio.h>
1313
#include <linux/interrupt.h>
14-
#include <linux/kernel.h>
1514
#include <linux/module.h>
15+
#include <linux/printk.h>
1616

1717
/* Macro DECLARE_TASKLET_OLD exists for compatibiity.
1818
* See https://lwn.net/Articles/830964/

examples/completions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <linux/completion.h>
55
#include <linux/err.h> /* for IS_ERR() */
66
#include <linux/init.h>
7-
#include <linux/kernel.h>
87
#include <linux/kthread.h>
98
#include <linux/module.h>
9+
#include <linux/printk.h>
1010

1111
static struct {
1212
struct completion crank_comp;

examples/example_atomic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44
#include <linux/atomic.h>
55
#include <linux/bitops.h>
6-
#include <linux/kernel.h>
76
#include <linux/module.h>
7+
#include <linux/printk.h>
88

99
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
1010
#define BYTE_TO_BINARY(byte) \

examples/example_mutex.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* example_mutex.c
33
*/
4-
#include <linux/kernel.h>
54
#include <linux/module.h>
65
#include <linux/mutex.h>
6+
#include <linux/printk.h>
77

88
static DEFINE_MUTEX(mymutex);
99

examples/example_rwlock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* example_rwlock.c
33
*/
4-
#include <linux/kernel.h>
54
#include <linux/module.h>
5+
#include <linux/printk.h>
66
#include <linux/rwlock.h>
77

88
static DEFINE_RWLOCK(myrwlock);

examples/example_spinlock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* example_spinlock.c
33
*/
44
#include <linux/init.h>
5-
#include <linux/kernel.h>
65
#include <linux/module.h>
6+
#include <linux/printk.h>
77
#include <linux/spinlock.h>
88

99
static DEFINE_SPINLOCK(sl_static);

examples/example_tasklet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44
#include <linux/delay.h>
55
#include <linux/interrupt.h>
6-
#include <linux/kernel.h>
76
#include <linux/module.h>
7+
#include <linux/printk.h>
88

99
/* Macro DECLARE_TASKLET_OLD exists for compatibility.
1010
* See https://lwn.net/Articles/830964/

examples/hello-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* hello-1.c - The simplest kernel module.
33
*/
4-
#include <linux/kernel.h> /* Needed for pr_info() */
54
#include <linux/module.h> /* Needed by all modules */
5+
#include <linux/printk.h> /* Needed for pr_info() */
66

77
int init_module(void)
88
{

examples/hello-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* This is preferred over using init_module() and cleanup_module().
44
*/
55
#include <linux/init.h> /* Needed for the macros */
6-
#include <linux/kernel.h> /* Needed for pr_info() */
76
#include <linux/module.h> /* Needed by all modules */
7+
#include <linux/printk.h> /* Needed for pr_info() */
88

99
static int __init hello_2_init(void)
1010
{

examples/hello-3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* hello-3.c - Illustrating the __init, __initdata and __exit macros.
33
*/
44
#include <linux/init.h> /* Needed for the macros */
5-
#include <linux/kernel.h> /* Needed for pr_info() */
65
#include <linux/module.h> /* Needed by all modules */
6+
#include <linux/printk.h> /* Needed for pr_info() */
77

88
static int hello3_data __initdata = 3;
99

examples/hello-4.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* hello-4.c - Demonstrates module documentation.
33
*/
44
#include <linux/init.h> /* Needed for the macros */
5-
#include <linux/kernel.h> /* Needed for pr_info() */
65
#include <linux/module.h> /* Needed by all modules */
6+
#include <linux/printk.h> /* Needed for pr_info() */
77

88
MODULE_LICENSE("GPL");
99
MODULE_AUTHOR("LKMPG");

examples/hello-5.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
* hello-5.c - Demonstrates command line argument passing to a module.
33
*/
44
#include <linux/init.h>
5-
#include <linux/kernel.h>
5+
#include <linux/kernel.h> /* for ARRAY_SIZE() */
66
#include <linux/module.h>
77
#include <linux/moduleparam.h>
8+
#include <linux/printk.h>
89
#include <linux/stat.h>
910

1011
MODULE_LICENSE("GPL");

examples/intrpt.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
#include <linux/gpio.h>
1212
#include <linux/interrupt.h>
13-
#include <linux/kernel.h>
13+
#include <linux/kernel.h> /* for ARRAY_SIZE() */
1414
#include <linux/module.h>
15+
#include <linux/printk.h>
1516

1617
static int button_irqs[] = { -1, -1 };
1718

examples/sleep.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
#include <linux/atomic.h>
77
#include <linux/fs.h>
8-
#include <linux/kernel.h> /* We're doing kernel work */
8+
#include <linux/kernel.h> /* for sprintf() */
99
#include <linux/module.h> /* Specifically, a module */
10+
#include <linux/printk.h>
1011
#include <linux/proc_fs.h> /* Necessary because we use proc fs */
1112
#include <linux/types.h>
1213
#include <linux/uaccess.h> /* for get_user and put_user */

lkmpg.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ \subsection{The Simplest Module}
401401
402402
Lastly, every kernel module needs to include \verb|<linux/module.h>|.
403403
% TODO: adjust the section anchor
404-
We needed to include \verb|<linux/kernel.h>| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}.
404+
We needed to include \verb|<linux/printk.h>| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}.
405405
406406
\begin{enumerate}
407407
\item A point about coding style.

0 commit comments

Comments
 (0)