diff options
author | Alexander Usyskin <alexander.usyskin@intel.com> | 2014-09-29 09:31:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-09-29 11:56:00 -0400 |
commit | c44952003fc949e81ae0a0297e91894d8724f7fe (patch) | |
tree | 49efe9b2d2ee60c0b8a5b0752ffa97ad0681a9d0 | |
parent | 1beeb4b9fbb27432f93ae8fe157228b7b897974a (diff) |
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>
-rw-r--r-- | drivers/misc/mei/debugfs.c | 22 |
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, | |||
29 | { | 29 | { |
30 | struct mei_device *dev = fp->private_data; | 30 | struct mei_device *dev = fp->private_data; |
31 | struct mei_me_client *me_cl; | 31 | struct mei_me_client *me_cl; |
32 | const size_t bufsz = 1024; | 32 | size_t bufsz = 1; |
33 | char *buf = kzalloc(bufsz, GFP_KERNEL); | 33 | char *buf; |
34 | int i = 0; | 34 | int i = 0; |
35 | int pos = 0; | 35 | int pos = 0; |
36 | int ret; | 36 | int ret; |
37 | 37 | ||
38 | if (!buf) | 38 | #define HDR " |id|addr| UUID |con|msg len|\n" |
39 | return -ENOMEM; | ||
40 | |||
41 | pos += scnprintf(buf + pos, bufsz - pos, | ||
42 | " |id|addr| UUID |con|msg len|\n"); | ||
43 | 39 | ||
44 | mutex_lock(&dev->device_lock); | 40 | mutex_lock(&dev->device_lock); |
45 | 41 | ||
42 | list_for_each_entry(me_cl, &dev->me_clients, list) | ||
43 | bufsz++; | ||
44 | |||
45 | bufsz *= sizeof(HDR) + 1; | ||
46 | buf = kzalloc(bufsz, GFP_KERNEL); | ||
47 | if (!buf) { | ||
48 | mutex_unlock(&dev->device_lock); | ||
49 | return -ENOMEM; | ||
50 | } | ||
51 | |||
52 | pos += scnprintf(buf + pos, bufsz - pos, HDR); | ||
53 | |||
46 | /* if the driver is not enabled the list won't be consistent */ | 54 | /* if the driver is not enabled the list won't be consistent */ |
47 | if (dev->dev_state != MEI_DEV_ENABLED) | 55 | if (dev->dev_state != MEI_DEV_ENABLED) |
48 | goto out; | 56 | goto out; |