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/chardev.c b/examples/chardev.c index a337d19..7972304 100644 --- a/examples/chardev.c +++ b/examples/chardev.c @@ -3,15 +3,19 @@ * you have read from the dev file */ +#include #include #include #include #include #include -#include -#include +#include /* for sprintf() */ #include -#include +#include +#include +#include /* for get_user and put_user */ + +#include /* Prototypes - this would normally go in a .h file */ static int device_open(struct inode *, struct file *); diff --git a/examples/chardev2.c b/examples/chardev2.c index 58ed57b..4c8b930 100644 --- a/examples/chardev2.c +++ b/examples/chardev2.c @@ -2,15 +2,17 @@ * chardev2.c - Create an input/output character device */ +#include #include #include #include #include #include -#include -#include /* We are doing kernel work */ #include /* Specifically, a module */ -#include +#include +#include + +#include #include "chardev.h" #define SUCCESS 0 diff --git a/examples/completions.c b/examples/completions.c index dddf5d7..e9a87c6 100644 --- a/examples/completions.c +++ b/examples/completions.c @@ -2,10 +2,11 @@ * completions.c */ #include +#include /* for IS_ERR() */ #include -#include #include #include +#include static struct { struct completion crank_comp; diff --git a/examples/devicemodel.c b/examples/devicemodel.c index f2d97dc..6fe923e 100644 --- a/examples/devicemodel.c +++ b/examples/devicemodel.c @@ -63,7 +63,6 @@ static struct platform_driver devicemodel_driver = { .driver = { .name = "devicemodel_example", - .owner = THIS_MODULE, .pm = &devicemodel_pm_ops, }, .probe = devicemodel_probe, diff --git a/examples/example_atomic.c b/examples/example_atomic.c index 02d770f..7ae8fb8 100644 --- a/examples/example_atomic.c +++ b/examples/example_atomic.c @@ -1,9 +1,10 @@ /* * example_atomic.c */ -#include -#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 4eaf823..6baf61f 100644 --- a/examples/example_mutex.c +++ b/examples/example_mutex.c @@ -1,10 +1,9 @@ /* * example_mutex.c */ -#include -#include #include #include +#include static DEFINE_MUTEX(mymutex); diff --git a/examples/example_rwlock.c b/examples/example_rwlock.c index 74a903f..3bdcb14 100644 --- a/examples/example_rwlock.c +++ b/examples/example_rwlock.c @@ -1,9 +1,9 @@ /* * example_rwlock.c */ -#include -#include #include +#include +#include static DEFINE_RWLOCK(myrwlock); diff --git a/examples/example_spinlock.c b/examples/example_spinlock.c index 5b69df1..483034f 100644 --- a/examples/example_spinlock.c +++ b/examples/example_spinlock.c @@ -2,9 +2,8 @@ * example_spinlock.c */ #include -#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 931ff5d..ad8c1dd 100644 --- a/examples/sleep.c +++ b/examples/sleep.c @@ -3,13 +3,20 @@ * at the same time, put all but one to sleep. */ -#include /* We're doing kernel work */ +#include +#include +#include /* for sprintf() */ #include /* Specifically, a module */ +#include #include /* Necessary because we use proc fs */ -#include /* For putting processes to sleep and - waking them up */ +#include #include /* for get_user and put_user */ #include +#include /* For putting processes to sleep and + waking them up */ + +#include +#include #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) #define HAVE_PROC_OPS 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.