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 <linux/atomic.h>.

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 <linux/irq.h> included?

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
Andy Shevchenko 2023-02-22 17:43:27 +02:00
parent e07bf16bfd
commit e62dff0df4
8 changed files with 24 additions and 12 deletions

View File

@ -3,15 +3,19 @@
* you have read from the dev file * you have read from the dev file
*/ */
#include <linux/atomic.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/irq.h> #include <linux/kernel.h> /* for sprintf() */
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/poll.h> #include <linux/printk.h>
#include <linux/types.h>
#include <linux/uaccess.h> /* for get_user and put_user */
#include <asm/errno.h>
/* Prototypes - this would normally go in a .h file */ /* Prototypes - this would normally go in a .h file */
static int device_open(struct inode *, struct file *); static int device_open(struct inode *, struct file *);

View File

@ -2,15 +2,17 @@
* chardev2.c - Create an input/output character device * chardev2.c - Create an input/output character device
*/ */
#include <linux/atomic.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/irq.h>
#include <linux/kernel.h> /* We are doing kernel work */
#include <linux/module.h> /* Specifically, a module */ #include <linux/module.h> /* Specifically, a module */
#include <linux/poll.h> #include <linux/printk.h>
#include <linux/types.h>
#include <asm/errno.h>
#include "chardev.h" #include "chardev.h"
#define SUCCESS 0 #define SUCCESS 0

View File

@ -2,6 +2,7 @@
* completions.c * completions.c
*/ */
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/err.h> /* for IS_ERR() */
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kthread.h> #include <linux/kthread.h>

View File

@ -1,7 +1,8 @@
/* /*
* example_atomic.c * example_atomic.c
*/ */
#include <linux/interrupt.h> #include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>

View File

@ -1,7 +1,6 @@
/* /*
* example_mutex.c * example_mutex.c
*/ */
#include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>

View File

@ -1,9 +1,9 @@
/* /*
* example_rwlock.c * example_rwlock.c
*/ */
#include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/rwlock.h>
static DEFINE_RWLOCK(myrwlock); static DEFINE_RWLOCK(myrwlock);

View File

@ -2,7 +2,6 @@
* example_spinlock.c * example_spinlock.c
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>

View File

@ -3,13 +3,19 @@
* at the same time, put all but one to sleep. * at the same time, put all but one to sleep.
*/ */
#include <linux/atomic.h>
#include <linux/fs.h>
#include <linux/kernel.h> /* We're doing kernel work */ #include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */ #include <linux/module.h> /* Specifically, a module */
#include <linux/proc_fs.h> /* Necessary because we use proc fs */ #include <linux/proc_fs.h> /* Necessary because we use proc fs */
#include <linux/sched.h> /* For putting processes to sleep and #include <linux/types.h>
waking them up */
#include <linux/uaccess.h> /* for get_user and put_user */ #include <linux/uaccess.h> /* for get_user and put_user */
#include <linux/version.h> #include <linux/version.h>
#include <linux/wait.h> /* For putting processes to sleep and
waking them up */
#include <asm/current.h>
#include <asm/errno.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
#define HAVE_PROC_OPS #define HAVE_PROC_OPS