Skip to content

Commit de47725

Browse files
author
Paul Gortmaker
committed
include: replace linux/module.h with "struct module" wherever possible
The <linux/module.h> pretty much brings in the kitchen sink along with it, so it should be avoided wherever reasonably possible in terms of being included from other commonly used <linux/something.h> files, as it results in a measureable increase on compile times. The worst culprit was probably device.h since it is used everywhere. This file also had an implicit dependency/usage of mutex.h which was masked by module.h, and is also fixed here at the same time. There are over a dozen other headers that simply declare the struct instead of pulling in the whole file, so follow their lead and simply make it a few more. Most of the implicit dependencies on module.h being present by these headers pulling it in have been now weeded out, so we can finally make this change with hopefully minimal breakage. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent eb5589a commit de47725

22 files changed

Lines changed: 34 additions & 22 deletions

‎include/drm/drmP.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
* can build the DRM (part of PI DRI). 4/21/2000 S + B */
4343
#include <asm/current.h>
4444
#endif /* __alpha__ */
45-
#include <linux/module.h>
4645
#include <linux/kernel.h>
4746
#include <linux/miscdevice.h>
4847
#include <linux/fs.h>
@@ -80,6 +79,8 @@
8079
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
8180
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
8281

82+
struct module;
83+
8384
struct drm_file;
8485
struct drm_device;
8586

‎include/linux/blkdev.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#include <linux/wait.h>
1515
#include <linux/mempool.h>
1616
#include <linux/bio.h>
17-
#include <linux/module.h>
1817
#include <linux/stringify.h>
1918
#include <linux/gfp.h>
2019
#include <linux/bsg.h>
2120
#include <linux/smp.h>
2221

2322
#include <asm/scatterlist.h>
2423

24+
struct module;
2525
struct scsi_ioctl_command;
2626

2727
struct request_queue;

‎include/linux/cpuidle.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
#include <linux/percpu.h>
1515
#include <linux/list.h>
16-
#include <linux/module.h>
1716
#include <linux/kobject.h>
1817
#include <linux/completion.h>
1918

2019
#define CPUIDLE_STATE_MAX 8
2120
#define CPUIDLE_NAME_LEN 16
2221
#define CPUIDLE_DESC_LEN 32
2322

23+
struct module;
24+
2425
struct cpuidle_device;
2526

2627

‎include/linux/device.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/lockdep.h>
2121
#include <linux/compiler.h>
2222
#include <linux/types.h>
23-
#include <linux/module.h>
23+
#include <linux/mutex.h>
2424
#include <linux/pm.h>
2525
#include <linux/atomic.h>
2626
#include <asm/device.h>
@@ -29,6 +29,7 @@ struct device;
2929
struct device_private;
3030
struct device_driver;
3131
struct driver_private;
32+
struct module;
3233
struct class;
3334
struct subsys_private;
3435
struct bus_type;

‎include/linux/firmware.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef _LINUX_FIRMWARE_H
22
#define _LINUX_FIRMWARE_H
33

4-
#include <linux/module.h>
54
#include <linux/types.h>
65
#include <linux/compiler.h>
76
#include <linux/gfp.h>
@@ -15,6 +14,7 @@ struct firmware {
1514
struct page **pages;
1615
};
1716

17+
struct module;
1818
struct device;
1919

2020
struct builtin_fw {

‎include/linux/ftrace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/kallsyms.h>
1111
#include <linux/linkage.h>
1212
#include <linux/bitops.h>
13-
#include <linux/module.h>
1413
#include <linux/ktime.h>
1514
#include <linux/sched.h>
1615
#include <linux/types.h>
@@ -19,6 +18,7 @@
1918

2019
#include <asm/ftrace.h>
2120

21+
struct module;
2222
struct ftrace_hash;
2323

2424
#ifdef CONFIG_FUNCTION_TRACER

‎include/linux/i2c.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <linux/types.h>
3030
#ifdef __KERNEL__
31-
#include <linux/module.h>
3231
#include <linux/mod_devicetable.h>
3332
#include <linux/device.h> /* for struct device */
3433
#include <linux/sched.h> /* for completion */
@@ -49,6 +48,8 @@ struct i2c_driver;
4948
union i2c_smbus_data;
5049
struct i2c_board_info;
5150

51+
struct module;
52+
5253
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
5354
/*
5455
* The master routines are the ones normally used to transmit data to devices

‎include/linux/ipmi.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,11 @@ struct kernel_ipmi_msg {
220220
* The in-kernel interface.
221221
*/
222222
#include <linux/list.h>
223-
#include <linux/module.h>
224223
#include <linux/device.h>
225224
#include <linux/proc_fs.h>
226225

226+
struct module;
227+
227228
/* Opaque type for a IPMI message user. One of these is needed to
228229
send and receive messages. */
229230
typedef struct ipmi_user *ipmi_user_t;

‎include/linux/ipmi_smi.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
#include <linux/ipmi_msgdefs.h>
3838
#include <linux/proc_fs.h>
39-
#include <linux/module.h>
4039
#include <linux/device.h>
4140
#include <linux/platform_device.h>
4241
#include <linux/ipmi.h>

‎include/linux/mdio-bitbang.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define __LINUX_MDIO_BITBANG_H
33

44
#include <linux/phy.h>
5-
#include <linux/module.h>
5+
6+
struct module;
67

78
struct mdiobb_ctrl;
89

0 commit comments

Comments
 (0)