aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2016-02-07 16:35:17 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 17:47:20 -0500
commit26900254827878c4f98c0d169f8ba290099b1ef3 (patch)
tree553a6dd2e767b77a929b96cba81a645c1212ef1a
parenta96c548291719ae40da1b3c52493f40a63d3dd84 (diff)
mei: debugfs: adjust active clients print buffer
In case of many active host clients clients (41 and more) 1K buffer is not enough for full information print. Calculate buffer size according to real clients number. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/debugfs.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index a138d8a27ab5..9f5410b98688 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -50,6 +50,7 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,
50 } 50 }
51 51
52 pos += scnprintf(buf + pos, bufsz - pos, HDR); 52 pos += scnprintf(buf + pos, bufsz - pos, HDR);
53#undef HDR
53 54
54 /* if the driver is not enabled the list won't be consistent */ 55 /* if the driver is not enabled the list won't be consistent */
55 if (dev->dev_state != MEI_DEV_ENABLED) 56 if (dev->dev_state != MEI_DEV_ENABLED)
@@ -90,23 +91,37 @@ static ssize_t mei_dbgfs_read_active(struct file *fp, char __user *ubuf,
90{ 91{
91 struct mei_device *dev = fp->private_data; 92 struct mei_device *dev = fp->private_data;
92 struct mei_cl *cl; 93 struct mei_cl *cl;
93 const size_t bufsz = 1024; 94 size_t bufsz = 1;
94 char *buf; 95 char *buf;
95 int i = 0; 96 int i = 0;
96 int pos = 0; 97 int pos = 0;
97 int ret; 98 int ret;
98 99
100#define HDR " |me|host|state|rd|wr|\n"
101
99 if (!dev) 102 if (!dev)
100 return -ENODEV; 103 return -ENODEV;
101 104
105 mutex_lock(&dev->device_lock);
106
107 /*
108 * if the driver is not enabled the list won't be consistent,
109 * we output empty table
110 */
111 if (dev->dev_state == MEI_DEV_ENABLED)
112 list_for_each_entry(cl, &dev->file_list, link)
113 bufsz++;
114
115 bufsz *= sizeof(HDR) + 1;
116
102 buf = kzalloc(bufsz, GFP_KERNEL); 117 buf = kzalloc(bufsz, GFP_KERNEL);
103 if (!buf) 118 if (!buf) {
119 mutex_unlock(&dev->device_lock);
104 return -ENOMEM; 120 return -ENOMEM;
121 }
105 122
106 pos += scnprintf(buf + pos, bufsz - pos, 123 pos += scnprintf(buf + pos, bufsz - pos, HDR);
107 " |me|host|state|rd|wr|\n"); 124#undef HDR
108
109 mutex_lock(&dev->device_lock);
110 125
111 /* if the driver is not enabled the list won't be consistent */ 126 /* if the driver is not enabled the list won't be consistent */
112 if (dev->dev_state != MEI_DEV_ENABLED) 127 if (dev->dev_state != MEI_DEV_ENABLED)
@@ -115,7 +130,7 @@ static ssize_t mei_dbgfs_read_active(struct file *fp, char __user *ubuf,
115 list_for_each_entry(cl, &dev->file_list, link) { 130 list_for_each_entry(cl, &dev->file_list, link) {
116 131
117 pos += scnprintf(buf + pos, bufsz - pos, 132 pos += scnprintf(buf + pos, bufsz - pos,
118 "%2d|%2d|%4d|%5d|%2d|%2d|\n", 133 "%3d|%2d|%4d|%5d|%2d|%2d|\n",
119 i, mei_cl_me_id(cl), cl->host_client_id, cl->state, 134 i, mei_cl_me_id(cl), cl->host_client_id, cl->state,
120 !list_empty(&cl->rd_completed), cl->writing_state); 135 !list_empty(&cl->rd_completed), cl->writing_state);
121 i++; 136 i++;