summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-06 20:05:36 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-06-21 03:32:17 -0400
commit2dcdc53bee40af958f31fdceee0d1f12ed58b95a (patch)
tree1a79a3dd5d8e273ccd61b7b174c5d049921a51eb
parent1e7c59be7c4182e3def3e8aa21895cc942dc8a55 (diff)
seq_buf: seq_buf_human_readable_u64()
This adds a seq_buf wrapper for string_get_size(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--include/linux/seq_buf.h2
-rw-r--r--lib/seq_buf.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
index 5b31c5147969..e5cfbcb113ed 100644
--- a/include/linux/seq_buf.h
+++ b/include/linux/seq_buf.h
@@ -159,4 +159,6 @@ extern int
seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
#endif
+void seq_buf_human_readable_u64(struct seq_buf *, u64);
+
#endif /* _LINUX_SEQ_BUF_H */
diff --git a/lib/seq_buf.c b/lib/seq_buf.c
index 0a68f7aa85d6..c4bd9ece2d33 100644
--- a/lib/seq_buf.c
+++ b/lib/seq_buf.c
@@ -395,3 +395,13 @@ int seq_buf_hex_dump(struct seq_buf *s, const char *prefix_str, int prefix_type,
}
return 0;
}
+
+void seq_buf_human_readable_u64(struct seq_buf *s, u64 v)
+{
+ char *buf;
+ size_t size = seq_buf_get_buf(s, &buf);
+ int wrote = string_get_size(v, 1, false, buf, size);
+
+ seq_buf_commit(s, wrote);
+}
+EXPORT_SYMBOL(seq_buf_human_readable_u64);