From nobody Wed Dec 17 20:40:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F16C27C40 for ; Wed, 22 Nov 2023 23:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344498AbjKVXZd (ORCPT ); Wed, 22 Nov 2023 18:25:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232389AbjKVXZb (ORCPT ); Wed, 22 Nov 2023 18:25:31 -0500 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F06A11F for ; Wed, 22 Nov 2023 15:25:28 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700695526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YRuFFmQdC+GEPgfI4SIAkxSEqgU4CuzXncjpbXVOgmA=; b=OYAGGmY34QArkmiHjXDebJ27PVWXyHMvnQZdKucHfTgjB1wcWYWZBFp8TmHRA8jCBIi8v4 yvW1Y2FRd872H0c4q3qoiHR5jVSk8jX1HncoAHfmzh1blP3uywzK+6Ze2zyzcQKJnohAOI ZqfJdF5DZ+e1jm6U7nga+mewJb4vhXs= From: Kent Overstreet To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 1/7] seq_buf: seq_buf_human_readable_u64() Date: Wed, 22 Nov 2023 18:25:06 -0500 Message-ID: <20231122232515.177833-2-kent.overstreet@linux.dev> In-Reply-To: <20231122232515.177833-1-kent.overstreet@linux.dev> References: <20231122232515.177833-1-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This adds a seq_buf wrapper for string_get_size(). Signed-off-by: Kent Overstreet --- include/linux/seq_buf.h | 4 ++++ lib/seq_buf.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 5fb1f12c33f9..dfcd0f367d6a 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -171,4 +171,8 @@ seq_buf_bprintf(struct seq_buf *s, const char *fmt, con= st u32 *binary); =20 void seq_buf_do_printk(struct seq_buf *s, const char *lvl); =20 +enum string_size_units; +void seq_buf_human_readable_u64(struct seq_buf *s, u64 v, + const enum string_size_units units); + #endif /* _LINUX_SEQ_BUF_H */ diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 010c730ca7fc..9d4e4d5f43b4 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -425,3 +425,13 @@ int seq_buf_hex_dump(struct seq_buf *s, const char *pr= efix_str, int prefix_type, } return 0; } + +void seq_buf_human_readable_u64(struct seq_buf *s, u64 v, const enum strin= g_size_units units) +{ + char *buf; + size_t size =3D seq_buf_get_buf(s, &buf); + int wrote =3D string_get_size(v, 1, units, buf, size); + + seq_buf_commit(s, wrote); +} +EXPORT_SYMBOL(seq_buf_human_readable_u64); --=20 2.42.0