aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/debugfs.c
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2014-09-29 16:31:34 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-29 11:56:00 -0400
commitc44952003fc949e81ae0a0297e91894d8724f7fe (patch)
tree49efe9b2d2ee60c0b8a5b0752ffa97ad0681a9d0 /drivers/misc/mei/debugfs.c
parentmei: add hbm and pg state in devstate debugfs print (diff)
downloadlinux-dev-c44952003fc949e81ae0a0297e91894d8724f7fe.tar.xz
linux-dev-c44952003fc949e81ae0a0297e91894d8724f7fe.zip
mei: debugfs: adjust print buffer
In case of many me clients (15 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>
Diffstat (limited to 'drivers/misc/mei/debugfs.c')
-rw-r--r--drivers/misc/mei/debugfs.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 2399b3181e6c..ca2a12d702a9 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -29,20 +29,28 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,
{
struct mei_device *dev = fp->private_data;
struct mei_me_client *me_cl;
- const size_t bufsz = 1024;
- char *buf = kzalloc(bufsz, GFP_KERNEL);
+ size_t bufsz = 1;
+ char *buf;
int i = 0;
int pos = 0;
int ret;
- if (!buf)
- return -ENOMEM;
-
- pos += scnprintf(buf + pos, bufsz - pos,
- " |id|addr| UUID |con|msg len|\n");
+#define HDR " |id|addr| UUID |con|msg len|\n"
mutex_lock(&dev->device_lock);
+ list_for_each_entry(me_cl, &dev->me_clients, list)
+ bufsz++;
+
+ bufsz *= sizeof(HDR) + 1;
+ buf = kzalloc(bufsz, GFP_KERNEL);
+ if (!buf) {
+ mutex_unlock(&dev->device_lock);
+ return -ENOMEM;
+ }
+
+ pos += scnprintf(buf + pos, bufsz - pos, HDR);
+
/* if the driver is not enabled the list won't be consistent */
if (dev->dev_state != MEI_DEV_ENABLED)
goto out;