ramips: raeth: add debugfs support
[librecmc/librecmc.git] / target / linux / ramips / files / drivers / net / ethernet / ramips / ramips_debugfs.c
1 /*
2  *  Ralink SoC ethernet driver debugfs code
3  *
4  *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/debugfs.h>
12 #include <linux/phy.h>
13
14 #include "ramips_eth.h"
15
16 static struct dentry *raeth_debugfs_root;
17
18 void raeth_debugfs_exit(struct raeth_priv *re)
19 {
20         debugfs_remove_recursive(re->debug.debugfs_dir);
21 }
22
23 int raeth_debugfs_init(struct raeth_priv *re)
24 {
25         re->debug.debugfs_dir = debugfs_create_dir(re->netdev->name,
26                                                    raeth_debugfs_root);
27         if (!re->debug.debugfs_dir)
28                 return -ENOMEM;
29
30         return 0;
31 }
32
33 int raeth_debugfs_root_init(void)
34 {
35         if (raeth_debugfs_root)
36                 return -EBUSY;
37
38         raeth_debugfs_root = debugfs_create_dir("raeth", NULL);
39         if (!raeth_debugfs_root)
40                 return -ENOENT;
41
42         return 0;
43 }
44
45 void raeth_debugfs_root_exit(void)
46 {
47         debugfs_remove(raeth_debugfs_root);
48         raeth_debugfs_root = NULL;
49 }