summaryrefslogtreecommitdiff
path: root/drivers/iommu/iommu-debug.c
diff options
context:
space:
mode:
authorMitchel Humpherys <mitchelh@codeaurora.org>2015-07-15 18:27:36 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:13:39 -0700
commit3053a46e6f2f9077260c6f5df8290d59a765fc4b (patch)
tree1147acac0c3e106ef1b8b0da0f0631378a09861e /drivers/iommu/iommu-debug.c
parent13ae3bcaca0fc47f4709b72cdba50ac3eed80198 (diff)
iommu: Create iommu debugfs directory from IOMMU code
Currently we're creating an "iommu" debugfs directory from the iommu-debug code. Other IOMMU modules might want to make use of this same directory, so create it from the IOMMU framework code itself. Change-Id: I679fdfc34ba5fcbd927dc5981438c6fabcfa3639 Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Diffstat (limited to 'drivers/iommu/iommu-debug.c')
-rw-r--r--drivers/iommu/iommu-debug.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/iommu/iommu-debug.c b/drivers/iommu/iommu-debug.c
index 72d4a89cae62..f7755441b408 100644
--- a/drivers/iommu/iommu-debug.c
+++ b/drivers/iommu/iommu-debug.c
@@ -22,8 +22,6 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
-static struct dentry *debugfs_top_dir;
-
#ifdef CONFIG_IOMMU_DEBUG_TRACKING
static DEFINE_MUTEX(iommu_debug_attachments_lock);
@@ -200,7 +198,7 @@ static int iommu_debug_init_tracking(void)
mutex_lock(&iommu_debug_attachments_lock);
debugfs_attachments_dir = debugfs_create_dir("attachments",
- debugfs_top_dir);
+ iommu_debugfs_top);
if (!debugfs_attachments_dir) {
pr_err("Couldn't create iommu/attachments debugfs directory\n");
ret = -ENODEV;
@@ -215,8 +213,14 @@ out_unlock:
mutex_unlock(&iommu_debug_attachments_lock);
return ret;
}
+
+static void iommu_debug_destroy_tracking(void)
+{
+ debugfs_remove_recursive(debugfs_attachments_dir);
+}
#else
static inline int iommu_debug_init_tracking(void) { return 0; }
+static inline void iommu_debug_destroy_tracking(void) { }
#endif
#ifdef CONFIG_IOMMU_TESTS
@@ -809,7 +813,7 @@ err:
static int iommu_debug_init_tests(void)
{
debugfs_tests_dir = debugfs_create_dir("tests",
- debugfs_top_dir);
+ iommu_debugfs_top);
if (!debugfs_tests_dir) {
pr_err("Couldn't create iommu/tests debugfs directory\n");
return -ENODEV;
@@ -818,33 +822,31 @@ static int iommu_debug_init_tests(void)
return bus_for_each_dev(&platform_bus_type, NULL, NULL,
snarf_iommu_devices);
}
+
+static void iommu_debug_destroy_tests(void)
+{
+ debugfs_remove_recursive(debugfs_tests_dir);
+}
#else
static inline int iommu_debug_init_tests(void) { return 0; }
+static inline void iommu_debug_destroy_tests(void) { }
#endif
static int iommu_debug_init(void)
{
- debugfs_top_dir = debugfs_create_dir("iommu", NULL);
- if (!debugfs_top_dir) {
- pr_err("Couldn't create iommu debugfs directory\n");
- return -ENODEV;
- }
-
if (iommu_debug_init_tracking())
- goto err;
+ return -ENODEV;
if (iommu_debug_init_tests())
- goto err;
+ return -ENODEV;
return 0;
-err:
- debugfs_remove_recursive(debugfs_top_dir);
- return -ENODEV;
}
static void iommu_debug_exit(void)
{
- debugfs_remove_recursive(debugfs_top_dir);
+ iommu_debug_destroy_tracking();
+ iommu_debug_destroy_tests();
}
module_init(iommu_debug_init);