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-05-13 00:22:30 -0400
commitcf1d4b24b33912db0d365c618bbf6dc42786a1ee (patch)
tree05ec0f5f4688664f3d3d2d9ee115f2aeaf0f1ce0
parentd24954c8ec3fb2e3dabbf51da27a164be181296b (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);