mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	Alexander Usyskin <alexander.usyskin@intel.com>,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 04/10] mei: debugfs: adjust print buffer
Date: Tue, 26 Aug 2014 00:53:22 +0300	[thread overview]
Message-ID: <1409003608-30274-4-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1409003608-30274-1-git-send-email-tomas.winkler@intel.com>

From: Alexander Usyskin <alexander.usyskin@intel.com>

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>
---
 drivers/misc/mei/debugfs.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 2399b31..ca2a12d 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;
-- 
1.9.3


  parent reply	other threads:[~2014-08-25 21:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25 21:53 [char-misc-next 01/10] mei: enable adding more IOCTL handlers Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 02/10] mei: use connect_data on the stack Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 03/10] mei: add hbm and pg state in devstate debugfs print Tomas Winkler
2014-08-25 21:53 ` Tomas Winkler [this message]
2014-08-25 21:53 ` [char-misc-next 05/10] mei: debugfs: add single buffer indicator Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 06/10] mei: pg: fix cat and paste error in comments Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 07/10] mei: fix style warning: Missing a blank line after declarations Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 08/10] mei: nfc: fix style warning Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 09/10] mei: kill error message for allocation failure Tomas Winkler
2014-08-25 21:53 ` [char-misc-next 10/10] mei: move mei_hbm_hdr function from hbm.h the hbm.c Tomas Winkler
2014-09-24  5:59 ` [char-misc-next 01/10] mei: enable adding more IOCTL handlers Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409003608-30274-4-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=alexander.usyskin@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®