From mboxrd@z Thu Jan 1 00:00:00 1970 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 EB470C4332F for ; Fri, 16 Dec 2022 20:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232081AbiLPUST (ORCPT ); Fri, 16 Dec 2022 15:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbiLPURs (ORCPT ); Fri, 16 Dec 2022 15:17:48 -0500 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1921872601 for ; Fri, 16 Dec 2022 12:17:33 -0800 (PST) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.19/8.17.1.19) with ESMTP id 2BGJxVB0024629 for ; Fri, 16 Dec 2022 12:17:33 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=MLWHDUS20C0jmHJ39hBO1H02jIUsWm5bZEXT2SOrcPk=; b=mfMn7jRAj1JALvXAGMrFFL2ynhUTkET2GZUP//Au3O898Gj3HgP6C83+obVffTaI9AEC LdH93rl62N9EjRD5+os0ye+85TMSG1HNxCqKKwVjcnoo9AYzjB9WKpmso7prETZ5tjzc 3HRP9xgLaR+p0coaQsxcCgS66JxPo99d6u33bkLP+D12zFt3zYgcMC02JjfrlJuH8gXo LYvJCI7ZTuPhY8i7TzUUu5iEU6bFUrUlcg/HAud+/dv1BAINn8D3AdXdX6uIibAi8w1U ySKVjeRciobFpyq04tF0c/gbUyK/rd7Wx3oq7ad63OgUBOIRgxK+2AB1dxOA/1eD9v5e Jg== Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3mg3hn2eff-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 16 Dec 2022 12:17:32 -0800 Received: from twshared15216.17.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 16 Dec 2022 12:17:24 -0800 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 143E1D042AB5; Fri, 16 Dec 2022 12:17:10 -0800 (PST) From: Keith Busch To: , , Matthew Wilcox CC: Tony Battersby , Kernel Team , Keith Busch Subject: [PATCHv2 03/11] dmapool: use sysfs_emit() instead of scnprintf() Date: Fri, 16 Dec 2022 12:16:17 -0800 Message-ID: <20221216201625.2362737-4-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221216201625.2362737-1-kbusch@meta.com> References: <20221216201625.2362737-1-kbusch@meta.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: qfc2w-Px_3l_LSo_6fiQmORoywmOr1Ul X-Proofpoint-ORIG-GUID: qfc2w-Px_3l_LSo_6fiQmORoywmOr1Ul X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-16_14,2022-12-15_02,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Battersby Use sysfs_emit instead of scnprintf, snprintf or sprintf. Signed-off-by: Tony Battersby Signed-off-by: Keith Busch --- mm/dmapool.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index 559207e1c3339..20616b760bb9c 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -64,18 +64,11 @@ static DEFINE_MUTEX(pools_reg_lock); =20 static ssize_t pools_show(struct device *dev, struct device_attribute *a= ttr, char *buf) { - unsigned temp; - unsigned size; - char *next; + int size; struct dma_page *page; struct dma_pool *pool; =20 - next =3D buf; - size =3D PAGE_SIZE; - - temp =3D scnprintf(next, size, "poolinfo - 0.1\n"); - size -=3D temp; - next +=3D temp; + size =3D sysfs_emit(buf, "poolinfo - 0.1\n"); =20 mutex_lock(&pools_lock); list_for_each_entry(pool, &dev->dma_pools, pools) { @@ -90,16 +83,14 @@ static ssize_t pools_show(struct device *dev, struct = device_attribute *attr, cha spin_unlock_irq(&pool->lock); =20 /* per-pool info, no real statistics yet */ - temp =3D scnprintf(next, size, "%-16s %4u %4zu %4zu %2u\n", - pool->name, blocks, - pages * (pool->allocation / pool->size), - pool->size, pages); - size -=3D temp; - next +=3D temp; + size +=3D sysfs_emit_at(buf, size, "%-16s %4u %4zu %4zu %2u\n", + pool->name, blocks, + pages * (pool->allocation / pool->size), + pool->size, pages); } mutex_unlock(&pools_lock); =20 - return PAGE_SIZE - size; + return size; } =20 static DEVICE_ATTR_RO(pools); --=20 2.30.2