Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+34 -22
+2 -1
include/drm/drmP.h
··· 42 42 * can build the DRM (part of PI DRI). 4/21/2000 S + B */ 43 43 #include <asm/current.h> 44 44 #endif /* __alpha__ */ 45 - #include <linux/module.h> 46 45 #include <linux/kernel.h> 47 46 #include <linux/miscdevice.h> 48 47 #include <linux/fs.h> ··· 78 79 79 80 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) 80 81 #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) 82 + 83 + struct module; 81 84 82 85 struct drm_file; 83 86 struct drm_device;
+1 -1
include/linux/blkdev.h
··· 14 14 #include <linux/wait.h> 15 15 #include <linux/mempool.h> 16 16 #include <linux/bio.h> 17 - #include <linux/module.h> 18 17 #include <linux/stringify.h> 19 18 #include <linux/gfp.h> 20 19 #include <linux/bsg.h> ··· 21 22 22 23 #include <asm/scatterlist.h> 23 24 25 + struct module; 24 26 struct scsi_ioctl_command; 25 27 26 28 struct request_queue;
+2 -1
include/linux/cpuidle.h
··· 13 13 14 14 #include <linux/percpu.h> 15 15 #include <linux/list.h> 16 - #include <linux/module.h> 17 16 #include <linux/kobject.h> 18 17 #include <linux/completion.h> 19 18 20 19 #define CPUIDLE_STATE_MAX 8 21 20 #define CPUIDLE_NAME_LEN 16 22 21 #define CPUIDLE_DESC_LEN 32 22 + 23 + struct module; 23 24 24 25 struct cpuidle_device; 25 26
+2 -1
include/linux/device.h
··· 20 20 #include <linux/lockdep.h> 21 21 #include <linux/compiler.h> 22 22 #include <linux/types.h> 23 - #include <linux/module.h> 23 + #include <linux/mutex.h> 24 24 #include <linux/pm.h> 25 25 #include <linux/atomic.h> 26 26 #include <asm/device.h> ··· 29 29 struct device_private; 30 30 struct device_driver; 31 31 struct driver_private; 32 + struct module; 32 33 struct class; 33 34 struct subsys_private; 34 35 struct bus_type;
+1 -1
include/linux/firmware.h
··· 1 1 #ifndef _LINUX_FIRMWARE_H 2 2 #define _LINUX_FIRMWARE_H 3 3 4 - #include <linux/module.h> 5 4 #include <linux/types.h> 6 5 #include <linux/compiler.h> 7 6 #include <linux/gfp.h> ··· 14 15 struct page **pages; 15 16 }; 16 17 18 + struct module; 17 19 struct device; 18 20 19 21 struct builtin_fw {
+1 -1
include/linux/ftrace.h
··· 10 10 #include <linux/kallsyms.h> 11 11 #include <linux/linkage.h> 12 12 #include <linux/bitops.h> 13 - #include <linux/module.h> 14 13 #include <linux/ktime.h> 15 14 #include <linux/sched.h> 16 15 #include <linux/types.h> ··· 18 19 19 20 #include <asm/ftrace.h> 20 21 22 + struct module; 21 23 struct ftrace_hash; 22 24 23 25 #ifdef CONFIG_FUNCTION_TRACER
+2 -1
include/linux/i2c.h
··· 28 28 29 29 #include <linux/types.h> 30 30 #ifdef __KERNEL__ 31 - #include <linux/module.h> 32 31 #include <linux/mod_devicetable.h> 33 32 #include <linux/device.h> /* for struct device */ 34 33 #include <linux/sched.h> /* for completion */ ··· 47 48 struct i2c_driver; 48 49 union i2c_smbus_data; 49 50 struct i2c_board_info; 51 + 52 + struct module; 50 53 51 54 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 52 55 /*
+2 -1
include/linux/ipmi.h
··· 220 220 * The in-kernel interface. 221 221 */ 222 222 #include <linux/list.h> 223 - #include <linux/module.h> 224 223 #include <linux/device.h> 225 224 #include <linux/proc_fs.h> 225 + 226 + struct module; 226 227 227 228 /* Opaque type for a IPMI message user. One of these is needed to 228 229 send and receive messages. */
-1
include/linux/ipmi_smi.h
··· 36 36 37 37 #include <linux/ipmi_msgdefs.h> 38 38 #include <linux/proc_fs.h> 39 - #include <linux/module.h> 40 39 #include <linux/device.h> 41 40 #include <linux/platform_device.h> 42 41 #include <linux/ipmi.h>
+2 -1
include/linux/mdio-bitbang.h
··· 2 2 #define __LINUX_MDIO_BITBANG_H 3 3 4 4 #include <linux/phy.h> 5 - #include <linux/module.h> 5 + 6 + struct module; 6 7 7 8 struct mdiobb_ctrl; 8 9
+2 -1
include/linux/mtd/mtd.h
··· 21 21 #define __MTD_MTD_H__ 22 22 23 23 #include <linux/types.h> 24 - #include <linux/module.h> 25 24 #include <linux/uio.h> 26 25 #include <linux/notifier.h> 27 26 #include <linux/device.h> ··· 123 124 __u32 oobavail; 124 125 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; 125 126 }; 127 + 128 + struct module; /* only needed for owner field in mtd_info */ 126 129 127 130 struct mtd_info { 128 131 u_char type;
+1 -1
include/linux/regmap.h
··· 15 15 16 16 #include <linux/device.h> 17 17 #include <linux/list.h> 18 - #include <linux/module.h> 19 18 19 + struct module; 20 20 struct i2c_client; 21 21 struct spi_device; 22 22
+2 -1
include/linux/sunrpc/svc_xprt.h
··· 8 8 #define SUNRPC_SVC_XPRT_H 9 9 10 10 #include <linux/sunrpc/svc.h> 11 - #include <linux/module.h> 11 + 12 + struct module; 12 13 13 14 struct svc_xprt_ops { 14 15 struct svc_xprt *(*xpo_create)(struct svc_serv *,
+2 -1
include/linux/textsearch.h
··· 4 4 #include <linux/types.h> 5 5 #include <linux/list.h> 6 6 #include <linux/kernel.h> 7 - #include <linux/module.h> 8 7 #include <linux/err.h> 9 8 #include <linux/slab.h> 9 + 10 + struct module; 10 11 11 12 struct ts_config; 12 13
+1 -1
include/linux/uio_driver.h
··· 14 14 #ifndef _UIO_DRIVER_H_ 15 15 #define _UIO_DRIVER_H_ 16 16 17 - #include <linux/module.h> 18 17 #include <linux/fs.h> 19 18 #include <linux/interrupt.h> 20 19 20 + struct module; 21 21 struct uio_map; 22 22 23 23 /**
+2 -1
include/linux/vlynq.h
··· 20 20 #define __VLYNQ_H__ 21 21 22 22 #include <linux/device.h> 23 - #include <linux/module.h> 24 23 #include <linux/types.h> 24 + 25 + struct module; 25 26 26 27 #define VLYNQ_NUM_IRQS 32 27 28
+2 -1
include/media/saa7146.h
··· 1 1 #ifndef __SAA7146__ 2 2 #define __SAA7146__ 3 3 4 - #include <linux/module.h> /* for module-version */ 5 4 #include <linux/delay.h> /* for delay-stuff */ 6 5 #include <linux/slab.h> /* for kmalloc/kfree */ 7 6 #include <linux/pci.h> /* for pci-config-stuff, vendor ids etc. */ ··· 45 46 46 47 #define SAA7146_ISR_CLEAR(x,y) \ 47 48 saa7146_write(x, ISR, (y)); 49 + 50 + struct module; 48 51 49 52 struct saa7146_dev; 50 53 struct saa7146_extension;
+2 -1
include/media/v4l2-int-device.h
··· 25 25 #ifndef V4L2_INT_DEVICE_H 26 26 #define V4L2_INT_DEVICE_H 27 27 28 - #include <linux/module.h> 29 28 #include <media/v4l2-common.h> 30 29 31 30 #define V4L2NAMESIZE 32 ··· 39 40 v4l2_int_type_master = 1, 40 41 v4l2_int_type_slave 41 42 }; 43 + 44 + struct module; 42 45 43 46 struct v4l2_int_device; 44 47
+2 -1
include/net/lib80211.h
··· 25 25 26 26 #include <linux/types.h> 27 27 #include <linux/list.h> 28 - #include <linux/module.h> 29 28 #include <linux/atomic.h> 30 29 #include <linux/if.h> 31 30 #include <linux/skbuff.h> ··· 40 41 enum { 41 42 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), 42 43 }; 44 + 45 + struct module; 43 46 44 47 struct lib80211_crypto_ops { 45 48 const char *name;
+1 -1
include/net/sock.h
··· 46 46 #include <linux/list_nulls.h> 47 47 #include <linux/timer.h> 48 48 #include <linux/cache.h> 49 - #include <linux/module.h> 50 49 #include <linux/lockdep.h> 51 50 #include <linux/netdevice.h> 52 51 #include <linux/skbuff.h> /* struct sk_buff */ ··· 728 729 struct timewait_sock_ops; 729 730 struct inet_hashinfo; 730 731 struct raw_hashinfo; 732 + struct module; 731 733 732 734 /* Networking protocol blocks we attach to sockets. 733 735 * socket layer -> transport layer interface
+1 -1
include/sound/core.h
··· 22 22 * 23 23 */ 24 24 25 - #include <linux/module.h> 26 25 #include <linux/sched.h> /* wake_up() */ 27 26 #include <linux/mutex.h> /* struct mutex */ 28 27 #include <linux/rwsem.h> /* struct rw_semaphore */ ··· 42 43 #ifdef CONFIG_PCI 43 44 struct pci_dev; 44 45 #endif 46 + struct module; 45 47 46 48 /* device allocation stuff */ 47 49
+1 -1
include/trace/events/module.h
··· 1 1 /* 2 2 * Because linux/module.h has tracepoints in the header, and ftrace.h 3 - * eventually includes this file, define_trace.h includes linux/module.h 3 + * used to include this file, define_trace.h includes linux/module.h 4 4 * But we do not want the module.h to override the TRACE_SYSTEM macro 5 5 * variable that define_trace.h is processing, so we only set it 6 6 * when module events are being processed, which would happen when