#include "hsr_main.h"
 #include "hsr_framereg.h"
 
+static struct dentry *hsr_debugfs_root_dir;
+
 static void print_mac_address(struct seq_file *sfp, unsigned char *mac)
 {
        seq_printf(sfp, "%02x:%02x:%02x:%02x:%02x:%02x:",
 {
        struct dentry *de = NULL;
 
-       de = debugfs_create_dir(hsr_dev->name, NULL);
+       de = debugfs_create_dir(hsr_dev->name, hsr_debugfs_root_dir);
        if (IS_ERR(de)) {
-               pr_err("Cannot create hsr debugfs root\n");
+               pr_err("Cannot create hsr debugfs directory\n");
                return;
        }
 
                                 priv->node_tbl_root, priv,
                                 &hsr_fops);
        if (IS_ERR(de)) {
-               pr_err("Cannot create hsr node_table directory\n");
+               pr_err("Cannot create hsr node_table file\n");
                debugfs_remove(priv->node_tbl_root);
                priv->node_tbl_root = NULL;
                return;
        debugfs_remove(priv->node_tbl_root);
        priv->node_tbl_root = NULL;
 }
+
+void hsr_debugfs_create_root(void)
+{
+       hsr_debugfs_root_dir = debugfs_create_dir("hsr", NULL);
+       if (IS_ERR(hsr_debugfs_root_dir)) {
+               pr_err("Cannot create hsr debugfs root directory\n");
+               hsr_debugfs_root_dir = NULL;
+       }
+}
+
+void hsr_debugfs_remove_root(void)
+{
+       /* debugfs_remove() internally checks NULL and ERROR */
+       debugfs_remove(hsr_debugfs_root_dir);
+}
 
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);
 void hsr_debugfs_term(struct hsr_priv *priv);
+void hsr_debugfs_create_root(void);
+void hsr_debugfs_remove_root(void);
 #else
 static inline void hsr_debugfs_init(struct hsr_priv *priv,
                                    struct net_device *hsr_dev)
 {}
 static inline void hsr_debugfs_term(struct hsr_priv *priv)
 {}
+static inline void hsr_debugfs_create_root(void)
+{}
+static inline void hsr_debugfs_remove_root(void)
+{}
 #endif
 
 #endif /*  __HSR_PRIVATE_H */