From 2b347a04f39752d7ee1aff3abe9d69560f53d4fd Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 26 May 2011 13:46:22 -0400 Subject: [PATCH] include: replace linux/module.h with "struct module" wherever possible The 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 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 --- include/drm/drmP.h | 3 ++- include/linux/blkdev.h | 2 +- include/linux/cpuidle.h | 3 ++- include/linux/device.h | 3 ++- include/linux/firmware.h | 2 +- include/linux/ftrace.h | 2 +- include/linux/i2c.h | 3 ++- include/linux/ipmi.h | 3 ++- include/linux/ipmi_smi.h | 1 - include/linux/mdio-bitbang.h | 3 ++- include/linux/mtd/mtd.h | 3 ++- include/linux/sunrpc/svc_xprt.h | 3 ++- include/linux/textsearch.h | 3 ++- include/linux/uio_driver.h | 2 +- include/linux/vlynq.h | 3 ++- include/media/saa7146.h | 3 ++- include/media/v4l2-int-device.h | 3 ++- include/net/lib80211.h | 3 ++- include/net/sock.h | 2 +- include/sound/core.h | 2 +- include/trace/define_trace.h | 2 +- include/trace/events/module.h | 2 +- 22 files changed, 34 insertions(+), 22 deletions(-) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 9b7c2bb4bb44..7e447f8415fc 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -42,7 +42,6 @@ * can build the DRM (part of PI DRI). 4/21/2000 S + B */ #include #endif /* __alpha__ */ -#include #include #include #include @@ -80,6 +79,8 @@ #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) +struct module; + struct drm_file; struct drm_device; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 0e67c45b3bc9..0e484b9d08d4 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include +struct module; struct scsi_ioctl_command; struct request_queue; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 36719ead50e8..4263b02711ba 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -21,6 +20,8 @@ #define CPUIDLE_NAME_LEN 16 #define CPUIDLE_DESC_LEN 32 +struct module; + struct cpuidle_device; diff --git a/include/linux/device.h b/include/linux/device.h index 2ee926c17303..00b3588e5984 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,6 +29,7 @@ struct device; struct device_private; struct device_driver; struct driver_private; +struct module; struct class; struct subsys_private; struct bus_type; diff --git a/include/linux/firmware.h b/include/linux/firmware.h index 21b3e7588abd..1e7c01189fa6 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -1,7 +1,6 @@ #ifndef _LINUX_FIRMWARE_H #define _LINUX_FIRMWARE_H -#include #include #include #include @@ -15,6 +14,7 @@ struct firmware { struct page **pages; }; +struct module; struct device; struct builtin_fw { diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index f0c0e8a47ae6..26eafcef75be 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include +struct module; struct ftrace_hash; #ifdef CONFIG_FUNCTION_TRACER diff --git a/include/linux/i2c.h b/include/linux/i2c.h index ce472e3767a0..3fad48568284 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -28,7 +28,6 @@ #include #ifdef __KERNEL__ -#include #include #include /* for struct device */ #include /* for completion */ @@ -48,6 +47,8 @@ struct i2c_driver; union i2c_smbus_data; struct i2c_board_info; +struct module; + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) /* * The master routines are the ones normally used to transmit data to devices diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h index ca85cf894e33..bbd156bb953b 100644 --- a/include/linux/ipmi.h +++ b/include/linux/ipmi.h @@ -220,10 +220,11 @@ struct kernel_ipmi_msg { * The in-kernel interface. */ #include -#include #include #include +struct module; + /* Opaque type for a IPMI message user. One of these is needed to send and receive messages. */ typedef struct ipmi_user *ipmi_user_t; diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h index 204f9cd26c16..3ef0d8b6aa6f 100644 --- a/include/linux/ipmi_smi.h +++ b/include/linux/ipmi_smi.h @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h index 8ea9a42a4c02..0fe00cd4c93c 100644 --- a/include/linux/mdio-bitbang.h +++ b/include/linux/mdio-bitbang.h @@ -2,7 +2,8 @@ #define __LINUX_MDIO_BITBANG_H #include -#include + +struct module; struct mdiobb_ctrl; diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 2541fb848daa..af31170e234b 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -21,7 +21,6 @@ #define __MTD_MTD_H__ #include -#include #include #include #include @@ -41,6 +40,8 @@ #define MTD_FAIL_ADDR_UNKNOWN -1LL +struct module; + /* If the erase fails, fail_addr might indicate exactly which block failed. If fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not specific to any particular block. */ diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index 7ad9751a0d87..8620f79658d4 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h @@ -8,7 +8,8 @@ #define SUNRPC_SVC_XPRT_H #include -#include + +struct module; struct svc_xprt_ops { struct svc_xprt *(*xpo_create)(struct svc_serv *, diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h index d9a85d616385..cfaee869146f 100644 --- a/include/linux/textsearch.h +++ b/include/linux/textsearch.h @@ -4,10 +4,11 @@ #include #include #include -#include #include #include +struct module; + struct ts_config; #define TS_AUTOLOAD 1 /* Automatically load textsearch modules when needed */ diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 04cdc4705878..e01c2334f507 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -14,10 +14,10 @@ #ifndef _UIO_DRIVER_H_ #define _UIO_DRIVER_H_ -#include #include #include +struct module; struct uio_map; /** diff --git a/include/linux/vlynq.h b/include/linux/vlynq.h index 8f6a95882b09..017d4a53d55e 100644 --- a/include/linux/vlynq.h +++ b/include/linux/vlynq.h @@ -20,9 +20,10 @@ #define __VLYNQ_H__ #include -#include #include +struct module; + #define VLYNQ_NUM_IRQS 32 struct vlynq_mapping { diff --git a/include/media/saa7146.h b/include/media/saa7146.h index 79827143d5ac..6e84cde44b82 100644 --- a/include/media/saa7146.h +++ b/include/media/saa7146.h @@ -1,7 +1,6 @@ #ifndef __SAA7146__ #define __SAA7146__ -#include /* for module-version */ #include /* for delay-stuff */ #include /* for kmalloc/kfree */ #include /* for pci-config-stuff, vendor ids etc. */ @@ -47,6 +46,8 @@ extern unsigned int saa7146_debug; #define SAA7146_ISR_CLEAR(x,y) \ saa7146_write(x, ISR, (y)); +struct module; + struct saa7146_dev; struct saa7146_extension; struct saa7146_vv; diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h index fbf585561570..e6aa2318367b 100644 --- a/include/media/v4l2-int-device.h +++ b/include/media/v4l2-int-device.h @@ -25,7 +25,6 @@ #ifndef V4L2_INT_DEVICE_H #define V4L2_INT_DEVICE_H -#include #include #define V4L2NAMESIZE 32 @@ -41,6 +40,8 @@ enum v4l2_int_type { v4l2_int_type_slave }; +struct module; + struct v4l2_int_device; struct v4l2_int_master { diff --git a/include/net/lib80211.h b/include/net/lib80211.h index b95bbb083ee8..4e57543166d7 100644 --- a/include/net/lib80211.h +++ b/include/net/lib80211.h @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -42,6 +41,8 @@ enum { IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), }; +struct module; + struct lib80211_crypto_ops { const char *name; struct list_head list; diff --git a/include/net/sock.h b/include/net/sock.h index 8e4062f165b8..4aa706caa202 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include /* struct sk_buff */ @@ -720,6 +719,7 @@ struct request_sock_ops; struct timewait_sock_ops; struct inet_hashinfo; struct raw_hashinfo; +struct module; /* Networking protocol blocks we attach to sockets. * socket layer -> transport layer interface diff --git a/include/sound/core.h b/include/sound/core.h index 1fa2407c966f..a91d78eb2f07 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -22,7 +22,6 @@ * */ -#include #include /* wake_up() */ #include /* struct mutex */ #include /* struct rw_semaphore */ @@ -43,6 +42,7 @@ #ifdef CONFIG_PCI struct pci_dev; #endif +struct module; /* device allocation stuff */ diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index da39b22636f7..4fd1de13c952 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h @@ -23,7 +23,7 @@ #include /* * module.h includes tracepoints, and because ftrace.h - * pulls in module.h: + * used to pull in module.h via this path: * trace/ftrace.h -> linux/ftrace_event.h -> linux/perf_event.h -> * linux/ftrace.h -> linux/module.h * we must include module.h here before we play with any of diff --git a/include/trace/events/module.h b/include/trace/events/module.h index 21a546d27c0c..161932737416 100644 --- a/include/trace/events/module.h +++ b/include/trace/events/module.h @@ -1,6 +1,6 @@ /* * Because linux/module.h has tracepoints in the header, and ftrace.h - * eventually includes this file, define_trace.h includes linux/module.h + * used to include this file, define_trace.h includes linux/module.h * But we do not want the module.h to override the TRACE_SYSTEM macro * variable that define_trace.h is processing, so we only set it * when module events are being processed, which would happen when -- 2.39.5