Skip to content

Commit e62dff0

Browse files
committed
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 <[email protected]>
1 parent e07bf16 commit e62dff0

File tree

8 files changed

+24
-12
lines changed

8 files changed

+24
-12
lines changed

examples/chardev.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
* you have read from the dev file
44
*/
55

6+
#include <linux/atomic.h>
67
#include <linux/cdev.h>
78
#include <linux/delay.h>
89
#include <linux/device.h>
910
#include <linux/fs.h>
1011
#include <linux/init.h>
11-
#include <linux/irq.h>
12-
#include <linux/kernel.h>
12+
#include <linux/kernel.h> /* for sprintf() */
1313
#include <linux/module.h>
14-
#include <linux/poll.h>
14+
#include <linux/printk.h>
15+
#include <linux/types.h>
16+
#include <linux/uaccess.h> /* for get_user and put_user */
17+
18+
#include <asm/errno.h>
1519

1620
/* Prototypes - this would normally go in a .h file */
1721
static int device_open(struct inode *, struct file *);

examples/chardev2.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
* chardev2.c - Create an input/output character device
33
*/
44

5+
#include <linux/atomic.h>
56
#include <linux/cdev.h>
67
#include <linux/delay.h>
78
#include <linux/device.h>
89
#include <linux/fs.h>
910
#include <linux/init.h>
10-
#include <linux/irq.h>
11-
#include <linux/kernel.h> /* We are doing kernel work */
1211
#include <linux/module.h> /* Specifically, a module */
13-
#include <linux/poll.h>
12+
#include <linux/printk.h>
13+
#include <linux/types.h>
14+
15+
#include <asm/errno.h>
1416

1517
#include "chardev.h"
1618
#define SUCCESS 0

examples/completions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* completions.c
33
*/
44
#include <linux/completion.h>
5+
#include <linux/err.h> /* for IS_ERR() */
56
#include <linux/init.h>
67
#include <linux/kernel.h>
78
#include <linux/kthread.h>

examples/example_atomic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
* example_atomic.c
33
*/
4-
#include <linux/interrupt.h>
4+
#include <linux/atomic.h>
5+
#include <linux/bitops.h>
56
#include <linux/kernel.h>
67
#include <linux/module.h>
78

examples/example_mutex.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* example_mutex.c
33
*/
4-
#include <linux/init.h>
54
#include <linux/kernel.h>
65
#include <linux/module.h>
76
#include <linux/mutex.h>

examples/example_rwlock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* example_rwlock.c
33
*/
4-
#include <linux/interrupt.h>
54
#include <linux/kernel.h>
65
#include <linux/module.h>
6+
#include <linux/rwlock.h>
77

88
static DEFINE_RWLOCK(myrwlock);
99

examples/example_spinlock.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* example_spinlock.c
33
*/
44
#include <linux/init.h>
5-
#include <linux/interrupt.h>
65
#include <linux/kernel.h>
76
#include <linux/module.h>
87
#include <linux/spinlock.h>

examples/sleep.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
* at the same time, put all but one to sleep.
44
*/
55

6+
#include <linux/atomic.h>
7+
#include <linux/fs.h>
68
#include <linux/kernel.h> /* We're doing kernel work */
79
#include <linux/module.h> /* Specifically, a module */
810
#include <linux/proc_fs.h> /* Necessary because we use proc fs */
9-
#include <linux/sched.h> /* For putting processes to sleep and
10-
waking them up */
11+
#include <linux/types.h>
1112
#include <linux/uaccess.h> /* for get_user and put_user */
1213
#include <linux/version.h>
14+
#include <linux/wait.h> /* For putting processes to sleep and
15+
waking them up */
16+
17+
#include <asm/current.h>
18+
#include <asm/errno.h>
1319

1420
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
1521
#define HAVE_PROC_OPS

0 commit comments

Comments
 (0)