[PATCH] FS-Cache: audit and remove any unnecessary uses of module.h

From: Paul Gortmaker
Date: Mon Sep 19 2016 - 16:36:38 EST


Historically a lot of these existed because we did not have
a distinction between what was modular code and what was providing
support to modules via EXPORT_SYMBOL and friends. That changed
when we forked out support for the latter into the export.h file.
This means we should be able to reduce the usage of module.h
in code that is obj-y Makefile or bool Kconfig.

In the case of some code where it is modular, we can extend that to
also include files that are building basic support functionality but
not related to loading or registering the final module; such files
also have no need whatsoever for module.h

The advantage in removing such instances is that module.h itself
sources about 15 other headers; adding significantly to what we feed
cpp, and it can obscure what headers we are effectively using.

Since module.h might have been the implicit source for init.h
(for __init) and for export.h (for EXPORT_SYMBOL) we consider each
instance for the presence of either and replace as needed.

We fix up an implict dependence on kobject.h that was being hidden
by the previous inclusion of module.h in the process.

Cc: David Howells <dhowells@xxxxxxxxxx>
Cc: linux-cachefs@xxxxxxxxxx
Signed-off-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx>
---

[I've been building this on linux-next on a regular basis for
allmodconfig for x86(32/64) ARM(32/64) ppc and mips so there
shouldn't be any unseen fallout.]

fs/fscache/cache.c | 3 ++-
fs/fscache/cookie.c | 2 +-
fs/fscache/fsdef.c | 2 +-
fs/fscache/histogram.c | 1 -
fs/fscache/netfs.c | 2 +-
fs/fscache/object-list.c | 1 -
fs/fscache/object.c | 2 +-
fs/fscache/operation.c | 2 +-
fs/fscache/page.c | 2 +-
fs/fscache/proc.c | 2 +-
fs/fscache/stats.c | 1 -
11 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c
index 56cce7fdd39e..4d769db94aaa 100644
--- a/fs/fscache/cache.c
+++ b/fs/fscache/cache.c
@@ -10,7 +10,8 @@
*/

#define FSCACHE_DEBUG_LEVEL CACHE
-#include <linux/module.h>
+#include <linux/export.h>
+#include <linux/kobject.h>
#include <linux/slab.h>
#include "internal.h"

diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 4304072161aa..6f3a3ff36e6e 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -13,7 +13,7 @@
*/

#define FSCACHE_DEBUG_LEVEL COOKIE
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/slab.h>
#include "internal.h"

diff --git a/fs/fscache/fsdef.c b/fs/fscache/fsdef.c
index 5a117df2a9ef..789d6893c2ac 100644
--- a/fs/fscache/fsdef.c
+++ b/fs/fscache/fsdef.c
@@ -10,7 +10,7 @@
*/

#define FSCACHE_DEBUG_LEVEL CACHE
-#include <linux/module.h>
+#include <linux/export.h>
#include "internal.h"

static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data,
diff --git a/fs/fscache/histogram.c b/fs/fscache/histogram.c
index 15a3d042247e..6e1b081301a3 100644
--- a/fs/fscache/histogram.c
+++ b/fs/fscache/histogram.c
@@ -10,7 +10,6 @@
*/

#define FSCACHE_DEBUG_LEVEL THREAD
-#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 9b28649df3a1..fda6d8a4bab7 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -10,7 +10,7 @@
*/

#define FSCACHE_DEBUG_LEVEL COOKIE
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/slab.h>
#include "internal.h"

diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index 5d5ddaa84b21..1f7a8f9f5415 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -10,7 +10,6 @@
*/

#define FSCACHE_DEBUG_LEVEL COOKIE
-#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/key.h>
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 9e792e30f4db..074e1aaed820 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -13,7 +13,7 @@
*/

#define FSCACHE_DEBUG_LEVEL COOKIE
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/slab.h>
#include <linux/prefetch.h>
#include "internal.h"
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index de67745e1cd7..d1e99b347800 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -12,7 +12,7 @@
*/

#define FSCACHE_DEBUG_LEVEL OPERATION
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include "internal.h"
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index c8c4f79c7ce1..35faa3ec8f28 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -10,7 +10,7 @@
*/

#define FSCACHE_DEBUG_LEVEL PAGE
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/fscache-cache.h>
#include <linux/buffer_head.h>
#include <linux/pagevec.h>
diff --git a/fs/fscache/proc.c b/fs/fscache/proc.c
index 1d9e4951a597..1c30b9ab67ab 100644
--- a/fs/fscache/proc.c
+++ b/fs/fscache/proc.c
@@ -10,7 +10,7 @@
*/

#define FSCACHE_DEBUG_LEVEL OPERATION
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"
diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
index 7ac6e839b065..0db2f6edb791 100644
--- a/fs/fscache/stats.c
+++ b/fs/fscache/stats.c
@@ -10,7 +10,6 @@
*/

#define FSCACHE_DEBUG_LEVEL THREAD
-#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"
--
2.8.4