linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-mmc@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Avri Altman <avri.altman@wdc.com>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Ming Lei <ming.lei@redhat.com>,
	YueHaibing <yuehaibing@huawei.com>,
	Zachary Hays <zhays@lexmark.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] mmc: make ext_csd dump more human-readable
Date: Fri, 31 Jan 2020 12:20:08 +0900	[thread overview]
Message-ID: <20200131032008.21354-1-yamada.masahiro@socionext.com> (raw)

The current ext_csd in the debugfs shows 1024 chars in one line,
which is unreadable at least for humans (but perhaps it could be
handier if somebody is processing it by a tool).

This commit makes the output format more human-readable; shows 8 byte
in each line, with address in the left-most column:

  0: 00 00 00 00 00 00 00 00
  8: 00 00 00 00 00 00 00 00
 16: 01 01 00 c0 6a 02 00 00
 24: 00 00 00 00 00 00 00 00
 32: 00 01 01 00 00 00 00 00
     <snip>
496: 05 00 03 01 20 3c 01 01
504: 01 00 00 00 00 00 00 00

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/core/block.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 663d87924e5e..79044b3cbd84 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2728,8 +2728,8 @@ static int mmc_dbg_card_status_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
 			 NULL, "%08llx\n");
 
-/* That is two digits * 512 + 1 for newline */
-#define EXT_CSD_STR_LEN 1025
+/* 3 chars (2 digits + space) for each byte, 5 additional chars for each line */
+#define EXT_CSD_STR_LEN		(512 * 3 + 512 / 8 * 5)
 
 static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 {
@@ -2740,7 +2740,7 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 	char *buf;
 	ssize_t n = 0;
 	u8 *ext_csd;
-	int err, i;
+	int err, i, j;
 
 	buf = kmalloc(EXT_CSD_STR_LEN + 1, GFP_KERNEL);
 	if (!buf)
@@ -2762,9 +2762,12 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 		goto out_free;
 	}
 
-	for (i = 0; i < 512; i++)
-		n += sprintf(buf + n, "%02x", ext_csd[i]);
-	n += sprintf(buf + n, "\n");
+	for (i = 0; i < 512; i += 8) {
+		n += sprintf(buf + n, "%3d:", i);
+		for (j = i; j < i + 8; j++)
+			n += sprintf(buf + n, " %02x", ext_csd[j]);
+		n += sprintf(buf + n, "\n");
+	}
 
 	if (n != EXT_CSD_STR_LEN) {
 		err = -EINVAL;
-- 
2.17.1


             reply	other threads:[~2020-01-31  3:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31  3:20 Masahiro Yamada [this message]
2020-01-31  6:17 ` [PATCH] mmc: make ext_csd dump more human-readable Avri Altman

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=20200131032008.21354-1-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=adrian.hunter@intel.com \
    --cc=avri.altman@wdc.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=ulf.hansson@linaro.org \
    --cc=yuehaibing@huawei.com \
    --cc=zhays@lexmark.com \
    /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;
as well as URLs for NNTP newsgroup(s).