Skip to contentSkip to conversation

compat: move debugfs_remove_recursive() to compat-2.6.27

PATCH Superseded Pavel Roskin 2 participants 4 messages Feb 20, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compat: move debugfs_remove_recursive() to compat-2.6.27

debugfs_remove_recursive() appeared in Linux 2.6.27, so it should be in compat-2.6.27, not in compat-2.6.26.

---
 compat/compat-2.6.26.c        |   32 --------------------------------
 compat/compat-2.6.27.c        |   33 +++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.26.h |    7 -------
 include/linux/compat-2.6.27.h |    9 +++++++++
 4 files changed, 42 insertions(+), 39 deletions(-)
compat/compat-2.6.26.c +0 -32
index 82134c2..b9bf9e7 100644
@@ -89,37 +89,5 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
 }
 EXPORT_SYMBOL_GPL(dev_set_name);
 
-/*
- * Backport of debugfs_remove_recursive() without using the internals globals
- * which are used by the kernel's version with:
- * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
- */
-void debugfs_remove_recursive(struct dentry *dentry)
-{
-	struct dentry *last = NULL;
-
-	/* Sanity checks */
-	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
-		return;
-
-	while (dentry != last) {
-		struct dentry *child = dentry;
-
-		/* Find a child without children */
-		while (!list_empty(&child->d_subdirs))
-			child = list_entry(child->d_subdirs.next,
-					   struct dentry,
-					   d_u.d_child);
-
-		/* Bail out if we already tried to remove that entry */
-		if (child == last)
-			return;
-
-		last = child;
-		debugfs_remove(child);
-	}
-}
-EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
-
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
 
compat/compat-2.6.27.c +33 -0
index 4fef36a..a226a0f 100644
@@ -12,6 +12,7 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
 
+#include <linux/debugfs.h>
 #include <linux/pci.h>
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
 #include <linux/mmc/sdio.h>
@@ -206,6 +207,38 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
 EXPORT_SYMBOL_GPL(sdio_align_size);
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
 
+/*
+ * Backport of debugfs_remove_recursive() without using the internals globals
+ * which are used by the kernel's version with:
+ * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ */
+void debugfs_remove_recursive(struct dentry *dentry)
+{
+	struct dentry *last = NULL;
+
+	/* Sanity checks */
+	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
+		return;
+
+	while (dentry != last) {
+		struct dentry *child = dentry;
+
+		/* Find a child without children */
+		while (!list_empty(&child->d_subdirs))
+			child = list_entry(child->d_subdirs.next,
+					   struct dentry,
+					   d_u.d_child);
+
+		/* Bail out if we already tried to remove that entry */
+		if (child == last)
+			return;
+
+		last = child;
+		debugfs_remove(child);
+	}
+}
+EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
+
 
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */
 
include/linux/compat-2.6.26.h +0 -7
index 498fe44..d98d2a6 100644
@@ -18,13 +18,6 @@
 #include <linux/fs.h>
 #include <linux/types.h>
 
-#if defined(CONFIG_DEBUG_FS)
-void debugfs_remove_recursive(struct dentry *dentry);
-#else
-static inline void debugfs_remove_recursive(struct dentry *dentry)
-{ }
-#endif
-
 /* These jiffie helpers added as of 2.6.26 */
 
 /*
include/linux/compat-2.6.27.h +9 -0
index e9de41e..72b6847 100644
@@ -214,4 +214,13 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
 
+struct dentry;
+
+#if defined(CONFIG_DEBUG_FS)
+void debugfs_remove_recursive(struct dentry *dentry);
+#else
+static inline void debugfs_remove_recursive(struct dentry *dentry)
+{ }
+#endif
+
 #endif /* LINUX_26_27_COMPAT_H */
#1 lore raw

PATCH v2 1/1 compat: move debugfs_remove_recursive() to compat-2.6.27

compat: move debugfs_remove_recursive() to compat-2.6.27

From: Pavel Roskin <[email protected]>

debugfs_remove_recursive() appeared in Linux 2.6.27, so it should be in compat-2.6.27, not in compat-2.6.26.

---

This is revision 2, with Signed-off-by and with linux/debugfs.h moved from compat-2.6.26.h to compat-2.6.27.h. I assume including Linux headers from compat headers is preferred over declaring the needed structures.

 compat/compat-2.6.26.c        |   32 --------------------------------
 compat/compat-2.6.27.c        |   32 ++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.26.h |    8 --------
 include/linux/compat-2.6.27.h |    8 ++++++++
 4 files changed, 40 insertions(+), 40 deletions(-)
compat/compat-2.6.26.c +0 -32
index 82134c2..b9bf9e7 100644
@@ -89,37 +89,5 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
 }
 EXPORT_SYMBOL_GPL(dev_set_name);
 
-/*
- * Backport of debugfs_remove_recursive() without using the internals globals
- * which are used by the kernel's version with:
- * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
- */
-void debugfs_remove_recursive(struct dentry *dentry)
-{
-	struct dentry *last = NULL;
-
-	/* Sanity checks */
-	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
-		return;
-
-	while (dentry != last) {
-		struct dentry *child = dentry;
-
-		/* Find a child without children */
-		while (!list_empty(&child->d_subdirs))
-			child = list_entry(child->d_subdirs.next,
-					   struct dentry,
-					   d_u.d_child);
-
-		/* Bail out if we already tried to remove that entry */
-		if (child == last)
-			return;
-
-		last = child;
-		debugfs_remove(child);
-	}
-}
-EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
-
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
 
compat/compat-2.6.27.c +32 -0
index 4fef36a..240f84f 100644
@@ -206,6 +206,38 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
 EXPORT_SYMBOL_GPL(sdio_align_size);
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
 
+/*
+ * Backport of debugfs_remove_recursive() without using the internals globals
+ * which are used by the kernel's version with:
+ * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ */
+void debugfs_remove_recursive(struct dentry *dentry)
+{
+	struct dentry *last = NULL;
+
+	/* Sanity checks */
+	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
+		return;
+
+	while (dentry != last) {
+		struct dentry *child = dentry;
+
+		/* Find a child without children */
+		while (!list_empty(&child->d_subdirs))
+			child = list_entry(child->d_subdirs.next,
+					   struct dentry,
+					   d_u.d_child);
+
+		/* Bail out if we already tried to remove that entry */
+		if (child == last)
+			return;
+
+		last = child;
+		debugfs_remove(child);
+	}
+}
+EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
+
 
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */
 
include/linux/compat-2.6.26.h +0 -8
index 498fe44..2bee30e 100644
@@ -11,20 +11,12 @@
 #include <linux/jiffies.h>
 #include <net/sock.h>
 #include <linux/fs.h>
-#include <linux/debugfs.h>
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
 #include <net/net_namespace.h>
 #endif
 #include <linux/fs.h>
 #include <linux/types.h>
 
-#if defined(CONFIG_DEBUG_FS)
-void debugfs_remove_recursive(struct dentry *dentry);
-#else
-static inline void debugfs_remove_recursive(struct dentry *dentry)
-{ }
-#endif
-
 /* These jiffie helpers added as of 2.6.26 */
 
 /*
include/linux/compat-2.6.27.h +8 -0
index e9de41e..f4c77ce 100644
@@ -5,6 +5,7 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
 
+#include <linux/debugfs.h>
 #include <linux/list.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
@@ -214,4 +215,11 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
 
+#if defined(CONFIG_DEBUG_FS)
+void debugfs_remove_recursive(struct dentry *dentry);
+#else
+static inline void debugfs_remove_recursive(struct dentry *dentry)
+{ }
+#endif
+
 #endif /* LINUX_26_27_COMPAT_H */
#2 lore raw

debugfs_remove_recursive() appeared in Linux 2.6.27, so it should be in compat-2.6.27, not in compat-2.6.26. Don't compile it if CONFIG_DEBUG_FS is disabled.

---

Sorry, I'm having a bad brain day. Revision 2 wasn't formatted right. What's worse, it would cause massive warnings on Linux 2.6.27 and newer. It would also fail on Linux 2.6.26 and older with debugfs disabled. This patch was tested on versions from 2.6.25 to 2.6.28 with and without debugfs.

 compat/compat-2.6.26.c        |   32 --------------------------------
 compat/compat-2.6.27.c        |   33 +++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.26.h |    8 --------
 include/linux/compat-2.6.27.h |    8 ++++++++
 4 files changed, 41 insertions(+), 40 deletions(-)
compat/compat-2.6.26.c +0 -32
index 82134c2..b9bf9e7 100644
@@ -89,37 +89,5 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
 }
 EXPORT_SYMBOL_GPL(dev_set_name);
 
-/*
- * Backport of debugfs_remove_recursive() without using the internals globals
- * which are used by the kernel's version with:
- * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
- */
-void debugfs_remove_recursive(struct dentry *dentry)
-{
-	struct dentry *last = NULL;
-
-	/* Sanity checks */
-	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
-		return;
-
-	while (dentry != last) {
-		struct dentry *child = dentry;
-
-		/* Find a child without children */
-		while (!list_empty(&child->d_subdirs))
-			child = list_entry(child->d_subdirs.next,
-					   struct dentry,
-					   d_u.d_child);
-
-		/* Bail out if we already tried to remove that entry */
-		if (child == last)
-			return;
-
-		last = child;
-		debugfs_remove(child);
-	}
-}
-EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
-
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
 
compat/compat-2.6.27.c +33 -0
index 4fef36a..b78d465 100644
@@ -206,6 +206,39 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
 EXPORT_SYMBOL_GPL(sdio_align_size);
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
 
+#ifdef CONFIG_DEBUG_FS
+/*
+ * Backport of debugfs_remove_recursive() without using the internals globals
+ * which are used by the kernel's version with:
+ * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ */
+void debugfs_remove_recursive(struct dentry *dentry)
+{
+	struct dentry *last = NULL;
+
+	/* Sanity checks */
+	if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
+		return;
+
+	while (dentry != last) {
+		struct dentry *child = dentry;
+
+		/* Find a child without children */
+		while (!list_empty(&child->d_subdirs))
+			child = list_entry(child->d_subdirs.next,
+					   struct dentry,
+					   d_u.d_child);
+
+		/* Bail out if we already tried to remove that entry */
+		if (child == last)
+			return;
+
+		last = child;
+		debugfs_remove(child);
+	}
+}
+EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
+#endif /* CONFIG_DEBUG_FS */
 
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */
 
include/linux/compat-2.6.26.h +0 -8
index 498fe44..2bee30e 100644
@@ -11,20 +11,12 @@
 #include <linux/jiffies.h>
 #include <net/sock.h>
 #include <linux/fs.h>
-#include <linux/debugfs.h>
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
 #include <net/net_namespace.h>
 #endif
 #include <linux/fs.h>
 #include <linux/types.h>
 
-#if defined(CONFIG_DEBUG_FS)
-void debugfs_remove_recursive(struct dentry *dentry);
-#else
-static inline void debugfs_remove_recursive(struct dentry *dentry)
-{ }
-#endif
-
 /* These jiffie helpers added as of 2.6.26 */
 
 /*
include/linux/compat-2.6.27.h +8 -0
index e9de41e..a690e2c 100644
@@ -5,6 +5,7 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
 
+#include <linux/debugfs.h>
 #include <linux/list.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
@@ -212,6 +213,13 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
 
 #endif /* arm */
 
+#if defined(CONFIG_DEBUG_FS)
+void debugfs_remove_recursive(struct dentry *dentry);
+#else
+static inline void debugfs_remove_recursive(struct dentry *dentry)
+{ }
+#endif
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
 
 #endif /* LINUX_26_27_COMPAT_H */
#3 lore raw
Quoted 5 lines · Pavel Roskin

debugfs_remove_recursive() appeared in Linux 2.6.27, so it should be in compat-2.6.27, not in compat-2.6.26.  Don't compile it if CONFIG_DEBUG_FS is disabled.

Thanks applied.

Luis