aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-01-14 16:21:41 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:09:35 -0500
commit5baaf71fb029f1256532b82aab90169615b94a7d (patch)
tree23c9c8c8bcbcd7c7e6fb418a5a1d8f75bb5457a2 /drivers
parent7d93e58d5374aef9cd895a7bb1a8903ffdb7c4b4 (diff)
mei: export active connections to debugfs
Export active connection state to debugfs The information displayed is [me,host] id pair, client connection state, and client's read and write states Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Reviewed-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/mei/debugfs.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index a3ae154444b2..ced5b777c70f 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -75,6 +75,54 @@ static const struct file_operations mei_dbgfs_fops_meclients = {
75 .llseek = generic_file_llseek, 75 .llseek = generic_file_llseek,
76}; 76};
77 77
78static ssize_t mei_dbgfs_read_active(struct file *fp, char __user *ubuf,
79 size_t cnt, loff_t *ppos)
80{
81 struct mei_device *dev = fp->private_data;
82 struct mei_cl *cl;
83 const size_t bufsz = 1024;
84 char *buf;
85 int i = 0;
86 int pos = 0;
87 int ret;
88
89 if (!dev)
90 return -ENODEV;
91
92 buf = kzalloc(bufsz, GFP_KERNEL);
93 if (!buf)
94 return -ENOMEM;
95
96 pos += scnprintf(buf + pos, bufsz - pos,
97 " |me|host|state|rd|wr|\n");
98
99 mutex_lock(&dev->device_lock);
100
101 /* if the driver is not enabled the list won't b consitent */
102 if (dev->dev_state != MEI_DEV_ENABLED)
103 goto out;
104
105 list_for_each_entry(cl, &dev->file_list, link) {
106
107 pos += scnprintf(buf + pos, bufsz - pos,
108 "%2d|%2d|%4d|%5d|%2d|%2d|\n",
109 i, cl->me_client_id, cl->host_client_id, cl->state,
110 cl->reading_state, cl->writing_state);
111 i++;
112 }
113out:
114 mutex_unlock(&dev->device_lock);
115 ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
116 kfree(buf);
117 return ret;
118}
119
120static const struct file_operations mei_dbgfs_fops_active = {
121 .open = simple_open,
122 .read = mei_dbgfs_read_active,
123 .llseek = generic_file_llseek,
124};
125
78static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf, 126static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf,
79 size_t cnt, loff_t *ppos) 127 size_t cnt, loff_t *ppos)
80{ 128{
@@ -128,6 +176,12 @@ int mei_dbgfs_register(struct mei_device *dev, const char *name)
128 dev_err(&dev->pdev->dev, "meclients: registration failed\n"); 176 dev_err(&dev->pdev->dev, "meclients: registration failed\n");
129 goto err; 177 goto err;
130 } 178 }
179 f = debugfs_create_file("active", S_IRUSR, dir,
180 dev, &mei_dbgfs_fops_active);
181 if (!f) {
182 dev_err(&dev->pdev->dev, "meclients: registration failed\n");
183 goto err;
184 }
131 f = debugfs_create_file("devstate", S_IRUSR, dir, 185 f = debugfs_create_file("devstate", S_IRUSR, dir,
132 dev, &mei_dbgfs_fops_devstate); 186 dev, &mei_dbgfs_fops_devstate);
133 if (!f) { 187 if (!f) {