1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifdef CONFIG_DEBUG_FS
25
26#include <linux/debugfs.h>
27#include <linux/seq_file.h>
28#include <linux/platform_device.h>
29
30#include "fjes.h"
31
32static struct dentry *fjes_debug_root;
33
34static const char * const ep_status_string[] = {
35 "unshared",
36 "shared",
37 "waiting",
38 "complete",
39};
40
41static int fjes_dbg_status_show(struct seq_file *m, void *v)
42{
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;
48
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');
60 }
61 }
62
63 return 0;
64}
65
66static int fjes_dbg_status_open(struct inode *inode, struct file *file)
67{
68 return single_open(file, fjes_dbg_status_show, inode->i_private);
69}
70
71static 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,
77};
78
79void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
80{
81 const char *name = dev_name(&adapter->plat_dev->dev);
82 struct dentry *pfile;
83
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;
89 }
90
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);
96}
97
98void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
99{
100 debugfs_remove_recursive(adapter->dbg_adapter);
101 adapter->dbg_adapter = NULL;
102}
103
104void fjes_dbg_init(void)
105{
106 fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
107 if (!fjes_debug_root)
108 pr_info("init of debugfs failed\n");
109}
110
111void fjes_dbg_exit(void)
112{
113 debugfs_remove_recursive(fjes_debug_root);
114 fjes_debug_root = NULL;
115}
116
117#endif
118