1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <linux/debugfs.h>
28#include <linux/delay.h>
29#include <linux/seq_file.h>
30#include <linux/interrupt.h>
31#include <linux/device.h>
32
33#include "../common/mic_dev.h"
34#include "mic_device.h"
35
36
37static struct dentry *mic_dbg;
38
39
40
41
42static int mic_intr_test(struct seq_file *s, void *unused)
43{
44 struct mic_driver *mdrv = s->private;
45 struct mic_device *mdev = &mdrv->mdev;
46
47 mic_send_intr(mdev, 0);
48 msleep(1000);
49 mic_send_intr(mdev, 1);
50 msleep(1000);
51 mic_send_intr(mdev, 2);
52 msleep(1000);
53 mic_send_intr(mdev, 3);
54 msleep(1000);
55
56 return 0;
57}
58
59static int mic_intr_test_open(struct inode *inode, struct file *file)
60{
61 return single_open(file, mic_intr_test, inode->i_private);
62}
63
64static int mic_intr_test_release(struct inode *inode, struct file *file)
65{
66 return single_release(inode, file);
67}
68
69static const struct file_operations intr_test_ops = {
70 .owner = THIS_MODULE,
71 .open = mic_intr_test_open,
72 .read = seq_read,
73 .llseek = seq_lseek,
74 .release = mic_intr_test_release
75};
76
77
78
79
80void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
81{
82 struct dentry *d;
83
84 if (!mic_dbg)
85 return;
86
87 mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
88 if (!mdrv->dbg_dir) {
89 dev_err(mdrv->dev, "Cant create dbg_dir %s\n", mdrv->name);
90 return;
91 }
92
93 d = debugfs_create_file("intr_test", 0444, mdrv->dbg_dir,
94 mdrv, &intr_test_ops);
95
96 if (!d) {
97 dev_err(mdrv->dev,
98 "Cant create dbg intr_test %s\n", mdrv->name);
99 return;
100 }
101}
102
103
104
105
106void mic_delete_card_debug_dir(struct mic_driver *mdrv)
107{
108 if (!mdrv->dbg_dir)
109 return;
110
111 debugfs_remove_recursive(mdrv->dbg_dir);
112}
113
114
115
116
117void __init mic_init_card_debugfs(void)
118{
119 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
120 if (!mic_dbg)
121 pr_err("can't create debugfs dir\n");
122}
123
124
125
126
127void mic_exit_card_debugfs(void)
128{
129 debugfs_remove(mic_dbg);
130}
131