aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/batman-adv/bat_debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/batman-adv/bat_debugfs.c')
-rw-r--r--drivers/staging/batman-adv/bat_debugfs.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/drivers/staging/batman-adv/bat_debugfs.c b/drivers/staging/batman-adv/bat_debugfs.c
new file mode 100644
index 00000000000..d5b28eb1c69
--- /dev/null
+++ b/drivers/staging/batman-adv/bat_debugfs.c
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2010 B.A.T.M.A.N. contributors:
3 *
4 * Marek Lindner
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA
19 *
20 */
21
22#include <linux/debugfs.h>
23
24#include "main.h"
25#include "bat_debugfs.h"
26#include "translation-table.h"
27#include "originator.h"
28#include "hard-interface.h"
29#include "vis.h"
30#include "icmp_socket.h"
31
32static struct dentry *bat_debugfs;
33
34void debugfs_init(void)
35{
36 bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL);
37}
38
39void debugfs_destroy(void)
40{
41 if (bat_debugfs) {
42 debugfs_remove_recursive(bat_debugfs);
43 bat_debugfs = NULL;
44 }
45}
46
47int debugfs_add_meshif(struct net_device *dev)
48{
49 struct bat_priv *bat_priv = netdev_priv(dev);
50
51 if (!bat_debugfs)
52 goto out;
53
54 bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs);
55 if (!bat_priv->debug_dir)
56 goto out;
57
58 bat_socket_setup(bat_priv);
59
60 return 0;
61out:
62#ifdef CONFIG_DEBUG_FS
63 return -ENOMEM;
64#else
65 return 0;
66#endif /* CONFIG_DEBUG_FS */
67}
68
69void debugfs_del_meshif(struct net_device *dev)
70{
71 struct bat_priv *bat_priv = netdev_priv(dev);
72
73 if (bat_debugfs) {
74 debugfs_remove_recursive(bat_priv->debug_dir);
75 bat_priv->debug_dir = NULL;
76 }
77}