mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "chaohang.cheng" <chengchaohang@163.com>
To: leon@kernel.org, maorg@nvidia.com, jgg@ziepe.ca,
	logang@deltatee.com, thunder.leizhen@huawei.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] lib/scatterlist: Provide scatterlist hexdump.
Date: Wed, 9 Feb 2022 11:42:39 +0800 (CST)	[thread overview]
Message-ID: <56c6ead2.33c5.17edc937b42.Coremail.chengchaohang@163.com> (raw)

From: "chaohang.cheng" <chaohang.cheng@horizon.ai>

A scatterlist hexdump is essential during debug, sometimes.

Signed-off-by: chaohang.cheng <chaohang.cheng@horizon.ai>
---
 include/linux/scatterlist.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 7ff9d6386c12..ef8ecaac0016 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -563,4 +563,21 @@ bool sg_miter_skip(struct sg_mapping_iter *miter, off_t offset);
 bool sg_miter_next(struct sg_mapping_iter *miter);
 void sg_miter_stop(struct sg_mapping_iter *miter);
 
+/*
+ * Hexdump scatterlist
+ *
+ * @sg: struct scatterlist* .
+ * it stands for the head of a scatterlist .
+ *
+ * note: print_hex_dump_debug is a dynamic debug .
+ *
+ */
+#define SG_HEXDUMP(sg)							\
+do {									\
+	struct scatterlist *sg_tmp = NULL;				\
+	for (sg_tmp = sg; sg_tmp; sg_tmp = sg_next(sg_tmp))		\
+		print_hex_dump_debug("", DUMP_PREFIX_OFFSET,		\
+			16, 1, sg_virt(sg_tmp), sg_tmp->length, true);	\
+} while (0)
+
 #endif /* _LINUX_SCATTERLIST_H */
-- 
2.25.1

             reply	other threads:[~2022-02-09  4:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  3:42 chaohang.cheng [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-10  3:13 chaohang.cheng
2022-02-09  3:51 chengchaohang
2022-02-09  3:36 chengchaohang
2022-02-09  3:34 chengchaohang

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=56c6ead2.33c5.17edc937b42.Coremail.chengchaohang@163.com \
    --to=chengchaohang@163.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=maorg@nvidia.com \
    --cc=thunder.leizhen@huawei.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

all inboxes | Powered by JetHome®