Skip to contentSkip to conversation

Reduce <linux/debugfs.h> dependencies

PATCH Applied Roland Dreier 2 participants 2 messages Mar 28, 2005 – Apr 8, 2005 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reduce <linux/debugfs.h> dependencies

The current <linux/debugfs.h> include file is a little fragile in that it is not self-contained and hence may cause compile warnings or errors depending on the files included before it, the kernel config and the architecture. This patch makes things a little more robust by:

- including <linux/types.h> to get definitions of u32, mode_t, and so on.
- forward declaring struct file_operations.
- including <linux/err.h> when CONFIG_DEBUG_FS is not set

The last change is particularly useful, as a kernel developer is likely to build with debugfs always enabled and never see the build breakage cased if debugfs is disabled.

include/linux/debugfs.h +7 -0
Index: linux-export/include/linux/debugfs.h
===================================================================
@@ -15,6 +15,10 @@
 #ifndef _DEBUGFS_H_
 #define _DEBUGFS_H_
 
+#include <linux/types.h>
+
+struct file_operations;
+
 #if defined(CONFIG_DEBUG_FS)
 struct dentry *debugfs_create_file(const char *name, mode_t mode,
 				   struct dentry *parent, void *data,
@@ -34,6 +38,9 @@
 				  struct dentry *parent, u32 *value);
 
 #else
+
+#include <linux/err.h>
+
 /* 
  * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  * so users have a chance to detect if there was a real error or not.  We don't
Applied
#1 lore raw
Quoted 9 lines · Roland Dreier

The current <linux/debugfs.h> include file is a little fragile in that it is not self-contained and hence may cause compile warnings or errors depending on the files included before it, the kernel config and the architecture. This patch makes things a little more robust by:

- including <linux/types.h> to get definitions of u32, mode_t, and so on.
- forward declaring struct file_operations.
- including <linux/err.h> when CONFIG_DEBUG_FS is not set

Quoted 5 lines

The last change is particularly useful, as a kernel developer is likely to build with debugfs always enabled and never see the build breakage cased if debugfs is disabled.

Applied, thanks.

greg k-h