From b8bbcd8a07a6fd124408804d7ea9a85a8d66d64f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 23 Feb 2023 12:41:23 +0200 Subject: [PATCH] treewide: Replace kernel.h by printk.h The kernel.h should be discouraged for use. Signed-off-by: Andy Shevchenko --- examples/bottomhalf.c | 2 +- examples/completions.c | 2 +- examples/example_atomic.c | 2 +- examples/example_mutex.c | 2 +- examples/example_rwlock.c | 2 +- examples/example_spinlock.c | 2 +- examples/example_tasklet.c | 2 +- examples/hello-1.c | 2 +- examples/hello-2.c | 2 +- examples/hello-3.c | 2 +- examples/hello-4.c | 2 +- examples/hello-5.c | 3 ++- examples/intrpt.c | 3 ++- examples/sleep.c | 3 ++- lkmpg.tex | 2 +- 15 files changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/bottomhalf.c b/examples/bottomhalf.c index 91be30e..a4cbf5e 100644 --- a/examples/bottomhalf.c +++ b/examples/bottomhalf.c @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include /* Macro DECLARE_TASKLET_OLD exists for compatibiity. * See https://lwn.net/Articles/830964/ diff --git a/examples/completions.c b/examples/completions.c index 197dea9..e9a87c6 100644 --- a/examples/completions.c +++ b/examples/completions.c @@ -4,9 +4,9 @@ #include #include /* for IS_ERR() */ #include -#include #include #include +#include static struct { struct completion crank_comp; diff --git a/examples/example_atomic.c b/examples/example_atomic.c index 4cd4897..7ae8fb8 100644 --- a/examples/example_atomic.c +++ b/examples/example_atomic.c @@ -3,8 +3,8 @@ */ #include #include -#include #include +#include #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" #define BYTE_TO_BINARY(byte) \ diff --git a/examples/example_mutex.c b/examples/example_mutex.c index 3149c23..6baf61f 100644 --- a/examples/example_mutex.c +++ b/examples/example_mutex.c @@ -1,9 +1,9 @@ /* * example_mutex.c */ -#include #include #include +#include static DEFINE_MUTEX(mymutex); diff --git a/examples/example_rwlock.c b/examples/example_rwlock.c index 9668e75..3bdcb14 100644 --- a/examples/example_rwlock.c +++ b/examples/example_rwlock.c @@ -1,8 +1,8 @@ /* * example_rwlock.c */ -#include #include +#include #include static DEFINE_RWLOCK(myrwlock); diff --git a/examples/example_spinlock.c b/examples/example_spinlock.c index 862291b..483034f 100644 --- a/examples/example_spinlock.c +++ b/examples/example_spinlock.c @@ -2,8 +2,8 @@ * example_spinlock.c */ #include -#include #include +#include #include static DEFINE_SPINLOCK(sl_static); diff --git a/examples/example_tasklet.c b/examples/example_tasklet.c index 49c825e..bd894dc 100644 --- a/examples/example_tasklet.c +++ b/examples/example_tasklet.c @@ -3,8 +3,8 @@ */ #include #include -#include #include +#include /* Macro DECLARE_TASKLET_OLD exists for compatibility. * See https://lwn.net/Articles/830964/ diff --git a/examples/hello-1.c b/examples/hello-1.c index 0abcf64..12f1a5d 100644 --- a/examples/hello-1.c +++ b/examples/hello-1.c @@ -1,8 +1,8 @@ /* * hello-1.c - The simplest kernel module. */ -#include /* Needed for pr_info() */ #include /* Needed by all modules */ +#include /* Needed for pr_info() */ int init_module(void) { diff --git a/examples/hello-2.c b/examples/hello-2.c index b5c360d..d76e716 100644 --- a/examples/hello-2.c +++ b/examples/hello-2.c @@ -3,8 +3,8 @@ * This is preferred over using init_module() and cleanup_module(). */ #include /* Needed for the macros */ -#include /* Needed for pr_info() */ #include /* Needed by all modules */ +#include /* Needed for pr_info() */ static int __init hello_2_init(void) { diff --git a/examples/hello-3.c b/examples/hello-3.c index a82c385..84ea2c1 100644 --- a/examples/hello-3.c +++ b/examples/hello-3.c @@ -2,8 +2,8 @@ * hello-3.c - Illustrating the __init, __initdata and __exit macros. */ #include /* Needed for the macros */ -#include /* Needed for pr_info() */ #include /* Needed by all modules */ +#include /* Needed for pr_info() */ static int hello3_data __initdata = 3; diff --git a/examples/hello-4.c b/examples/hello-4.c index 8e2937d..c029761 100644 --- a/examples/hello-4.c +++ b/examples/hello-4.c @@ -2,8 +2,8 @@ * hello-4.c - Demonstrates module documentation. */ #include /* Needed for the macros */ -#include /* Needed for pr_info() */ #include /* Needed by all modules */ +#include /* Needed for pr_info() */ MODULE_LICENSE("GPL"); MODULE_AUTHOR("LKMPG"); diff --git a/examples/hello-5.c b/examples/hello-5.c index 5978e71..3447855 100644 --- a/examples/hello-5.c +++ b/examples/hello-5.c @@ -2,9 +2,10 @@ * hello-5.c - Demonstrates command line argument passing to a module. */ #include -#include +#include /* for ARRAY_SIZE() */ #include #include +#include #include MODULE_LICENSE("GPL"); diff --git a/examples/intrpt.c b/examples/intrpt.c index 0a6b252..beeddd6 100644 --- a/examples/intrpt.c +++ b/examples/intrpt.c @@ -10,8 +10,9 @@ #include #include -#include +#include /* for ARRAY_SIZE() */ #include +#include static int button_irqs[] = { -1, -1 }; diff --git a/examples/sleep.c b/examples/sleep.c index dff612a..ad8c1dd 100644 --- a/examples/sleep.c +++ b/examples/sleep.c @@ -5,8 +5,9 @@ #include #include -#include /* We're doing kernel work */ +#include /* for sprintf() */ #include /* Specifically, a module */ +#include #include /* Necessary because we use proc fs */ #include #include /* for get_user and put_user */ diff --git a/lkmpg.tex b/lkmpg.tex index d2fa59d..1976fee 100644 --- a/lkmpg.tex +++ b/lkmpg.tex @@ -401,7 +401,7 @@ The \cpp|cleanup_module()| function is supposed to undo whatever \cpp|init_modul Lastly, every kernel module needs to include \verb||. % TODO: adjust the section anchor -We needed to include \verb|| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}. +We needed to include \verb|| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}. \begin{enumerate} \item A point about coding style.