From e62dff0df4baddcae6a07f229a644dd8700abe3c Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 22 Feb 2023 17:43:27 +0200 Subject: [PATCH] treewide: Clean up the headers The rule of thumb is to include the headers we are the direct user of. In particular, if we need an atomic API, we include . On the other hand we should not use headers for no reason. In particular, if we are not doing any IRQ job, why is the included? Signed-off-by: Andy Shevchenko --- examples/chardev.c | 10 +++++++--- examples/chardev2.c | 8 +++++--- examples/completions.c | 1 + examples/example_atomic.c | 3 ++- examples/example_mutex.c | 1 - examples/example_rwlock.c | 2 +- examples/example_spinlock.c | 1 - examples/sleep.c | 10 ++++++++-- 8 files changed, 24 insertions(+), 12 deletions(-) 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..197dea9 100644 --- a/examples/completions.c +++ b/examples/completions.c @@ -2,6 +2,7 @@ * completions.c */ #include +#include /* for IS_ERR() */ #include #include #include diff --git a/examples/example_atomic.c b/examples/example_atomic.c index 02d770f..4cd4897 100644 --- a/examples/example_atomic.c +++ b/examples/example_atomic.c @@ -1,7 +1,8 @@ /* * example_atomic.c */ -#include +#include +#include #include #include diff --git a/examples/example_mutex.c b/examples/example_mutex.c index 4eaf823..3149c23 100644 --- a/examples/example_mutex.c +++ b/examples/example_mutex.c @@ -1,7 +1,6 @@ /* * example_mutex.c */ -#include #include #include #include diff --git a/examples/example_rwlock.c b/examples/example_rwlock.c index 74a903f..9668e75 100644 --- a/examples/example_rwlock.c +++ b/examples/example_rwlock.c @@ -1,9 +1,9 @@ /* * example_rwlock.c */ -#include #include #include +#include static DEFINE_RWLOCK(myrwlock); diff --git a/examples/example_spinlock.c b/examples/example_spinlock.c index 5b69df1..862291b 100644 --- a/examples/example_spinlock.c +++ b/examples/example_spinlock.c @@ -2,7 +2,6 @@ * example_spinlock.c */ #include -#include #include #include #include diff --git a/examples/sleep.c b/examples/sleep.c index 931ff5d..dff612a 100644 --- a/examples/sleep.c +++ b/examples/sleep.c @@ -3,13 +3,19 @@ * at the same time, put all but one to sleep. */ +#include +#include #include /* We're doing kernel work */ #include /* Specifically, a module */ #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