From a9bf211db2574435fbed4c835dbff0ff10108ce1 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 19 Feb 2010 20:17:42 -0500 Subject: [PATCH] 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. Don't compile it if CONFIG_DEBUG_FS is disabled. Signed-off-by: Pavel Roskin --- 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(-) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index 82134c21235b..b9bf9e768956 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -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) */ diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index 4fef36ab8710..b78d4653891f 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -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) */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 498fe44cff3d..2bee30eca755 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,20 +11,12 @@ #include #include #include -#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #endif #include #include -#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 */ /* diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index e9de41eed5ed..a690e2c4350a 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -5,6 +5,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) +#include #include #include #include @@ -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 */ -- 2.30.2