Skip to content

Commit

Permalink
include: replace linux/module.h with "struct module" wherever possible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
paulgortmaker committed Oct 31, 2011
1 parent eb5589a commit de47725
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 22 deletions.
3 changes: 2 additions & 1 deletion include/drm/drmP.h
Expand Up @@ -42,7 +42,6 @@
* can build the DRM (part of PI DRI). 4/21/2000 S + B */
#include <asm/current.h>
#endif /* __alpha__ */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion include/linux/blkdev.h
Expand Up @@ -14,14 +14,14 @@
#include <linux/wait.h>
#include <linux/mempool.h>
#include <linux/bio.h>
#include <linux/module.h>
#include <linux/stringify.h>
#include <linux/gfp.h>
#include <linux/bsg.h>
#include <linux/smp.h>

#include <asm/scatterlist.h>

struct module;
struct scsi_ioctl_command;

struct request_queue;
Expand Down
3 changes: 2 additions & 1 deletion include/linux/cpuidle.h
Expand Up @@ -13,14 +13,15 @@

#include <linux/percpu.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/completion.h>

#define CPUIDLE_STATE_MAX 8
#define CPUIDLE_NAME_LEN 16
#define CPUIDLE_DESC_LEN 32

struct module;

struct cpuidle_device;


Expand Down
3 changes: 2 additions & 1 deletion include/linux/device.h
Expand Up @@ -20,7 +20,7 @@
#include <linux/lockdep.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm.h>
#include <linux/atomic.h>
#include <asm/device.h>
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/firmware.h
@@ -1,7 +1,6 @@
#ifndef _LINUX_FIRMWARE_H
#define _LINUX_FIRMWARE_H

#include <linux/module.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/gfp.h>
Expand All @@ -15,6 +14,7 @@ struct firmware {
struct page **pages;
};

struct module;
struct device;

struct builtin_fw {
Expand Down
2 changes: 1 addition & 1 deletion include/linux/ftrace.h
Expand Up @@ -10,7 +10,6 @@
#include <linux/kallsyms.h>
#include <linux/linkage.h>
#include <linux/bitops.h>
#include <linux/module.h>
#include <linux/ktime.h>
#include <linux/sched.h>
#include <linux/types.h>
Expand All @@ -19,6 +18,7 @@

#include <asm/ftrace.h>

struct module;
struct ftrace_hash;

#ifdef CONFIG_FUNCTION_TRACER
Expand Down
3 changes: 2 additions & 1 deletion include/linux/i2c.h
Expand Up @@ -28,7 +28,6 @@

#include <linux/types.h>
#ifdef __KERNEL__
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/device.h> /* for struct device */
#include <linux/sched.h> /* for completion */
Expand All @@ -49,6 +48,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
Expand Down
3 changes: 2 additions & 1 deletion include/linux/ipmi.h
Expand Up @@ -220,10 +220,11 @@ struct kernel_ipmi_msg {
* The in-kernel interface.
*/
#include <linux/list.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/proc_fs.h>

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;
Expand Down
1 change: 0 additions & 1 deletion include/linux/ipmi_smi.h
Expand Up @@ -36,7 +36,6 @@

#include <linux/ipmi_msgdefs.h>
#include <linux/proc_fs.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/ipmi.h>
Expand Down
3 changes: 2 additions & 1 deletion include/linux/mdio-bitbang.h
Expand Up @@ -2,7 +2,8 @@
#define __LINUX_MDIO_BITBANG_H

#include <linux/phy.h>
#include <linux/module.h>

struct module;

struct mdiobb_ctrl;

Expand Down
3 changes: 2 additions & 1 deletion include/linux/mtd/mtd.h
Expand Up @@ -21,7 +21,6 @@
#define __MTD_MTD_H__

#include <linux/types.h>
#include <linux/module.h>
#include <linux/uio.h>
#include <linux/notifier.h>
#include <linux/device.h>
Expand Down Expand Up @@ -125,6 +124,8 @@ struct nand_ecclayout {
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
};

struct module; /* only needed for owner field in mtd_info */

struct mtd_info {
u_char type;
uint32_t flags;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/regmap.h
Expand Up @@ -15,8 +15,8 @@

#include <linux/device.h>
#include <linux/list.h>
#include <linux/module.h>

struct module;
struct i2c_client;
struct spi_device;

Expand Down
3 changes: 2 additions & 1 deletion include/linux/sunrpc/svc_xprt.h
Expand Up @@ -8,7 +8,8 @@
#define SUNRPC_SVC_XPRT_H

#include <linux/sunrpc/svc.h>
#include <linux/module.h>

struct module;

struct svc_xprt_ops {
struct svc_xprt *(*xpo_create)(struct svc_serv *,
Expand Down
3 changes: 2 additions & 1 deletion include/linux/textsearch.h
Expand Up @@ -4,10 +4,11 @@
#include <linux/types.h>
#include <linux/list.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/slab.h>

struct module;

struct ts_config;

#define TS_AUTOLOAD 1 /* Automatically load textsearch modules when needed */
Expand Down
2 changes: 1 addition & 1 deletion include/linux/uio_driver.h
Expand Up @@ -14,10 +14,10 @@
#ifndef _UIO_DRIVER_H_
#define _UIO_DRIVER_H_

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/interrupt.h>

struct module;
struct uio_map;

/**
Expand Down
3 changes: 2 additions & 1 deletion include/linux/vlynq.h
Expand Up @@ -20,9 +20,10 @@
#define __VLYNQ_H__

#include <linux/device.h>
#include <linux/module.h>
#include <linux/types.h>

struct module;

#define VLYNQ_NUM_IRQS 32

struct vlynq_mapping {
Expand Down
3 changes: 2 additions & 1 deletion include/media/saa7146.h
@@ -1,7 +1,6 @@
#ifndef __SAA7146__
#define __SAA7146__

#include <linux/module.h> /* for module-version */
#include <linux/delay.h> /* for delay-stuff */
#include <linux/slab.h> /* for kmalloc/kfree */
#include <linux/pci.h> /* for pci-config-stuff, vendor ids etc. */
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion include/media/v4l2-int-device.h
Expand Up @@ -25,7 +25,6 @@
#ifndef V4L2_INT_DEVICE_H
#define V4L2_INT_DEVICE_H

#include <linux/module.h>
#include <media/v4l2-common.h>

#define V4L2NAMESIZE 32
Expand All @@ -41,6 +40,8 @@ enum v4l2_int_type {
v4l2_int_type_slave
};

struct module;

struct v4l2_int_device;

struct v4l2_int_master {
Expand Down
3 changes: 2 additions & 1 deletion include/net/lib80211.h
Expand Up @@ -25,7 +25,6 @@

#include <linux/types.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/atomic.h>
#include <linux/if.h>
#include <linux/skbuff.h>
Expand All @@ -42,6 +41,8 @@ enum {
IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
};

struct module;

struct lib80211_crypto_ops {
const char *name;
struct list_head list;
Expand Down
2 changes: 1 addition & 1 deletion include/net/sock.h
Expand Up @@ -46,7 +46,6 @@
#include <linux/list_nulls.h>
#include <linux/timer.h>
#include <linux/cache.h>
#include <linux/module.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h> /* struct sk_buff */
Expand Down Expand Up @@ -729,6 +728,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
Expand Down
2 changes: 1 addition & 1 deletion include/sound/core.h
Expand Up @@ -22,7 +22,6 @@
*
*/

#include <linux/module.h>
#include <linux/sched.h> /* wake_up() */
#include <linux/mutex.h> /* struct mutex */
#include <linux/rwsem.h> /* struct rw_semaphore */
Expand All @@ -43,6 +42,7 @@
#ifdef CONFIG_PCI
struct pci_dev;
#endif
struct module;

/* device allocation stuff */

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down

0 comments on commit de47725

Please sign in to comment.