Merge tag 'pwm/for-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
[linux/fpc-iii.git] / drivers / net / fjes / fjes_debugfs.c
blob30052ebd52bf47d97776d2752a3349490f19e9a9
1 /*
2 * FUJITSU Extended Socket Network Device driver
3 * Copyright (c) 2015-2016 FUJITSU LIMITED
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, see <http://www.gnu.org/licenses/>.
17 * The full GNU General Public License is included in this distribution in
18 * the file called "COPYING".
22 /* debugfs support for fjes driver */
24 #ifdef CONFIG_DEBUG_FS
26 #include <linux/debugfs.h>
27 #include <linux/seq_file.h>
28 #include <linux/platform_device.h>
30 #include "fjes.h"
32 static struct dentry *fjes_debug_root;
34 static const char * const ep_status_string[] = {
35 "unshared",
36 "shared",
37 "waiting",
38 "complete",
41 static int fjes_dbg_status_show(struct seq_file *m, void *v)
43 struct fjes_adapter *adapter = m->private;
44 struct fjes_hw *hw = &adapter->hw;
45 int max_epid = hw->max_epid;
46 int my_epid = hw->my_epid;
47 int epidx;
49 seq_puts(m, "EPID\tSTATUS SAME_ZONE CONNECTED\n");
50 for (epidx = 0; epidx < max_epid; epidx++) {
51 if (epidx == my_epid) {
52 seq_printf(m, "ep%d\t%-16c %-16c %-16c\n",
53 epidx, '-', '-', '-');
54 } else {
55 seq_printf(m, "ep%d\t%-16s %-16c %-16c\n",
56 epidx,
57 ep_status_string[fjes_hw_get_partner_ep_status(hw, epidx)],
58 fjes_hw_epid_is_same_zone(hw, epidx) ? 'Y' : 'N',
59 fjes_hw_epid_is_shared(hw->hw_info.share, epidx) ? 'Y' : 'N');
63 return 0;
66 static int fjes_dbg_status_open(struct inode *inode, struct file *file)
68 return single_open(file, fjes_dbg_status_show, inode->i_private);
71 static const struct file_operations fjes_dbg_status_fops = {
72 .owner = THIS_MODULE,
73 .open = fjes_dbg_status_open,
74 .read = seq_read,
75 .llseek = seq_lseek,
76 .release = single_release,
79 void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
81 const char *name = dev_name(&adapter->plat_dev->dev);
82 struct dentry *pfile;
84 adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
85 if (!adapter->dbg_adapter) {
86 dev_err(&adapter->plat_dev->dev,
87 "debugfs entry for %s failed\n", name);
88 return;
91 pfile = debugfs_create_file("status", 0444, adapter->dbg_adapter,
92 adapter, &fjes_dbg_status_fops);
93 if (!pfile)
94 dev_err(&adapter->plat_dev->dev,
95 "debugfs status for %s failed\n", name);
98 void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
100 debugfs_remove_recursive(adapter->dbg_adapter);
101 adapter->dbg_adapter = NULL;
104 void fjes_dbg_init(void)
106 fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
107 if (!fjes_debug_root)
108 pr_info("init of debugfs failed\n");
111 void fjes_dbg_exit(void)
113 debugfs_remove_recursive(fjes_debug_root);
114 fjes_debug_root = NULL;
117 #endif /* CONFIG_DEBUG_FS */