Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[firefly-linux-kernel-4.4.55.git] / drivers / net / bonding / bond_debugfs.c
1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/device.h>
4 #include <linux/netdevice.h>
5
6 #include "bonding.h"
7
8 #ifdef CONFIG_DEBUG_FS
9
10 #include <linux/debugfs.h>
11 #include <linux/seq_file.h>
12
13 static struct dentry *bonding_debug_root;
14
15 void bond_debug_register(struct bonding *bond)
16 {
17         if (!bonding_debug_root)
18                 return;
19
20         bond->debug_dir =
21                 debugfs_create_dir(bond->dev->name, bonding_debug_root);
22
23         if (!bond->debug_dir) {
24                 pr_warning("%s: Warning: failed to register to debugfs\n",
25                         bond->dev->name);
26                 return;
27         }
28 }
29
30 void bond_debug_unregister(struct bonding *bond)
31 {
32         if (!bonding_debug_root)
33                 return;
34
35         debugfs_remove_recursive(bond->debug_dir);
36 }
37
38 void bond_debug_reregister(struct bonding *bond)
39 {
40         struct dentry *d;
41
42         if (!bonding_debug_root)
43                 return;
44
45         d = debugfs_rename(bonding_debug_root, bond->debug_dir,
46                            bonding_debug_root, bond->dev->name);
47         if (d) {
48                 bond->debug_dir = d;
49         } else {
50                 pr_warning("%s: Warning: failed to reregister, "
51                                 "so just unregister old one\n",
52                                 bond->dev->name);
53                 bond_debug_unregister(bond);
54         }
55 }
56
57 void bond_create_debugfs(void)
58 {
59         bonding_debug_root = debugfs_create_dir("bonding", NULL);
60
61         if (!bonding_debug_root) {
62                 pr_warning("Warning: Cannot create bonding directory"
63                                 " in debugfs\n");
64         }
65 }
66
67 void bond_destroy_debugfs(void)
68 {
69         debugfs_remove_recursive(bonding_debug_root);
70         bonding_debug_root = NULL;
71 }
72
73
74 #else /* !CONFIG_DEBUG_FS */
75
76 void bond_debug_register(struct bonding *bond)
77 {
78 }
79
80 void bond_debug_unregister(struct bonding *bond)
81 {
82 }
83
84 void bond_debug_reregister(struct bonding *bond)
85 {
86 }
87
88 void bond_create_debugfs(void)
89 {
90 }
91
92 void bond_destroy_debugfs(void)
93 {
94 }
95
96 #endif /* CONFIG_DEBUG_FS */