diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-06 20:05:36 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-08-22 02:07:27 -0400 |
commit | 60a334be96a6bb2dc4517364f90cccb7339b557f (patch) | |
tree | a0de6118b25f3ac8d987f1c5f44a5f8549edd7e8 /lib/seq_buf.c | |
parent | 7d6d663fa4490b88753a235234800983fd73ed50 (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>
Diffstat (limited to 'lib/seq_buf.c')
-rw-r--r-- | lib/seq_buf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/seq_buf.c b/lib/seq_buf.c index f3f3436d60a9..3c41ca83a0c3 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -436,3 +436,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, const enum string_size_units units) +{ + char *buf; + size_t size = seq_buf_get_buf(s, &buf); + int wrote = string_get_size(v, 1, units, buf, size); + + seq_buf_commit(s, wrote); +} +EXPORT_SYMBOL(seq_buf_human_readable_u64); |