aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-03-24 04:04:11 -0400
committerTejun Heo <tj@kernel.org>2010-03-30 09:02:32 -0400
commit5a0e3ad6af8660be21ca98a971cd00f331318c05 (patch)
tree5bfb7be11a03176a87296a43ac6647975c00a1d1 /drivers/base
parented391f4ebf8f701d3566423ce8f17e614cde9806 (diff)
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c1
-rw-r--r--drivers/base/cpu.c1
-rw-r--r--drivers/base/devres.c1
-rw-r--r--drivers/base/devtmpfs.c1
-rw-r--r--drivers/base/dma-coherent.c1
-rw-r--r--drivers/base/dma-mapping.c1
-rw-r--r--drivers/base/driver.c1
-rw-r--r--drivers/base/firmware_class.c1
-rw-r--r--drivers/base/memory.c1
-rw-r--r--drivers/base/module.c1
-rw-r--r--drivers/base/node.c1
-rw-r--r--drivers/base/sys.c1
12 files changed, 11 insertions, 1 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 71f6af5c8b0b..12eec3f633b1 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/slab.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include "base.h" 19#include "base.h"
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index b5242e1e8bc4..f35719aab3c1 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -10,6 +10,7 @@
10#include <linux/topology.h> 10#include <linux/topology.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/node.h> 12#include <linux/node.h>
13#include <linux/gfp.h>
13 14
14#include "base.h" 15#include "base.h"
15 16
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 05dd307e8f02..cf7a0c788052 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12 13
13#include "base.h" 14#include "base.h"
14 15
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index dac478c6e460..057cf11326bf 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -23,6 +23,7 @@
23#include <linux/cred.h> 23#include <linux/cred.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/init_task.h> 25#include <linux/init_task.h>
26#include <linux/slab.h>
26 27
27static struct vfsmount *dev_mnt; 28static struct vfsmount *dev_mnt;
28 29
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 962a3b574f21..d4d8ce53886a 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -2,6 +2,7 @@
2 * Coherent per-device memory handling. 2 * Coherent per-device memory handling.
3 * Borrowed from i386 3 * Borrowed from i386
4 */ 4 */
5#include <linux/slab.h>
5#include <linux/kernel.h> 6#include <linux/kernel.h>
6#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
7 8
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index ca9186f70a69..763d59c1eb65 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
11#include <linux/gfp.h>
11 12
12/* 13/*
13 * Managed DMA API 14 * Managed DMA API
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 90c9fff09ead..b631f7c59453 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/slab.h>
16#include <linux/string.h> 17#include <linux/string.h>
17#include "base.h" 18#include "base.h"
18 19
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 18518ba13c81..985da11174e7 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -19,6 +19,7 @@
19#include <linux/kthread.h> 19#include <linux/kthread.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <linux/slab.h>
22 23
23#define to_dev(obj) container_of(obj, struct device, kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
24 25
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index db0848e54cc6..4f4aa5897b4c 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/stat.h> 24#include <linux/stat.h>
25#include <linux/slab.h>
25 26
26#include <asm/atomic.h> 27#include <asm/atomic.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
diff --git a/drivers/base/module.c b/drivers/base/module.c
index 103be9cacb05..f32f2f9b7be5 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -7,6 +7,7 @@
7#include <linux/device.h> 7#include <linux/device.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/slab.h>
10#include <linux/string.h> 11#include <linux/string.h>
11#include "base.h" 12#include "base.h"
12 13
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 93b3ac65c2d4..985abd7f49a7 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -15,6 +15,7 @@
15#include <linux/cpu.h> 15#include <linux/cpu.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/swap.h> 17#include <linux/swap.h>
18#include <linux/gfp.h>
18 19
19static struct sysdev_class_attribute *node_state_attrs[]; 20static struct sysdev_class_attribute *node_state_attrs[];
20 21
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 8980feec5d14..9354dc10a363 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -17,7 +17,6 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/string.h> 20#include <linux/string.h>
22#include <linux/pm.h> 21#include <linux/pm.h>
23#include <linux/device.h> 22#include <linux/device.h>