@@ -20,6 +20,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/debugfs.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/module.h>
@@ -45,6 +46,18 @@ static dev_t media_dev_t;
static DEFINE_MUTEX(media_devnode_lock);
static DECLARE_BITMAP(media_devnode_nums, MEDIA_NUM_DEVICES);
+static struct dentry *media_debugfs_root_dir;
+
+#ifdef CONFIG_DEBUG_FS
+struct dentry *media_debugfs_root(void)
+{
+ if (!media_debugfs_root_dir)
+ media_debugfs_root_dir = debugfs_create_dir("media", NULL);
+ return media_debugfs_root_dir;
+}
+EXPORT_SYMBOL_GPL(media_debugfs_root);
+#endif
+
/* Called when the last user of the media device exits. */
static void media_devnode_release(struct device *cd)
{
@@ -316,6 +329,8 @@ static void __exit media_devnode_exit(void)
{
bus_unregister(&media_bus_type);
unregister_chrdev_region(media_dev_t, MEDIA_NUM_DEVICES);
+ debugfs_remove_recursive(media_debugfs_root_dir);
+ media_debugfs_root_dir = NULL;
}
subsys_initcall(media_devnode_init);
@@ -165,4 +165,18 @@ static inline int media_devnode_is_registered(struct media_devnode *devnode)
return test_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
}
+/**
+ * media_debugfs_root - returns the dentry of the top-level "media" debugfs dir
+ *
+ * If this directory does not yet exist, then it will be created.
+ */
+#ifdef CONFIG_DEBUG_FS
+struct dentry *media_debugfs_root(void);
+#else
+static inline struct dentry *media_debugfs_root(void)
+{
+ return NULL;
+}
+#endif
+
#endif /* _MEDIA_DEVNODE_H */
This new function returns the dentry of the top-level debugfs "media" directory. If it does not exist yet, then it is created first. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> --- drivers/media/mc/mc-devnode.c | 15 +++++++++++++++ include/media/media-devnode.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+)