From nobody Thu Sep 18 07:19:05 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 1B761C63705 for ; Thu, 8 Dec 2022 07:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbiLHHXi (ORCPT ); Thu, 8 Dec 2022 02:23:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbiLHHXf (ORCPT ); Thu, 8 Dec 2022 02:23:35 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9188A46646; Wed, 7 Dec 2022 23:23:32 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NSQcM0rSdz8R041; Thu, 8 Dec 2022 15:23:31 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl1.zte.com.cn with SMTP id 2B87NPXn058403; Thu, 8 Dec 2022 15:23:25 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Thu, 8 Dec 2022 15:23:27 +0800 (CST) Date: Thu, 8 Dec 2022 15:23:27 +0800 (CST) X-Zmail-TransId: 2af9639190efffffffff94be3eda X-Mailer: Zmail v1.0 Message-ID: <202212081523277319144@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIG5ldC1uZXh0XSBzZmM6IENvbnZlcnQgdG8gdXNlIHN5c2ZzX2VtaXRfYXQoKSBBUEk=?= X-MAIL: mse-fl1.zte.com.cn 2B87NPXn058403 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 639190F3.000 by FangMail milter! X-FangMail-Envelope: 1670484211/4NSQcM0rSdz8R041/639190F3.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 639190F3.000/4NSQcM0rSdz8R041 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: ye xingchen Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: ye xingchen --- drivers/net/ethernet/sfc/mcdi.c | 14 ++++---------- drivers/net/ethernet/sfc/siena/mcdi.c | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcd= i.c index af338208eae9..73269db3ca39 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -210,14 +210,10 @@ static void efx_mcdi_send_request(struct efx_nic *efx= , unsigned cmd, * progress on a NIC at any one time. So no need for locking. */ for (i =3D 0; i < hdr_len / 4 && bytes < PAGE_SIZE; i++) - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(hdr[i].u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr[i].u32[0]= )); for (i =3D 0; i < inlen / 4 && bytes < PAGE_SIZE; i++) - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(inbuf[i].u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(inbuf[i].u32[= 0])); netif_info(efx, hw, efx->net_dev, "MCDI RPC REQ:%s\n", buf); } @@ -302,15 +298,13 @@ static void efx_mcdi_read_response_header(struct efx_= nic *efx) */ for (i =3D 0; i < hdr_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } for (i =3D 0; i < data_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len + (i * 4), 4); - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } netif_info(efx, hw, efx->net_dev, "MCDI RPC RESP:%s\n", buf); diff --git a/drivers/net/ethernet/sfc/siena/mcdi.c b/drivers/net/ethernet/s= fc/siena/mcdi.c index 3f7899daa86a..4e10d4594c3a 100644 --- a/drivers/net/ethernet/sfc/siena/mcdi.c +++ b/drivers/net/ethernet/sfc/siena/mcdi.c @@ -213,14 +213,10 @@ static void efx_mcdi_send_request(struct efx_nic *efx= , unsigned cmd, * progress on a NIC at any one time. So no need for locking. */ for (i =3D 0; i < hdr_len / 4 && bytes < PAGE_SIZE; i++) - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(hdr[i].u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr[i].u32[0]= )); for (i =3D 0; i < inlen / 4 && bytes < PAGE_SIZE; i++) - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(inbuf[i].u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(inbuf[i].u32[= 0])); netif_info(efx, hw, efx->net_dev, "MCDI RPC REQ:%s\n", buf); } @@ -305,15 +301,13 @@ static void efx_mcdi_read_response_header(struct efx_= nic *efx) */ for (i =3D 0; i < hdr_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } for (i =3D 0; i < data_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len + (i * 4), 4); - bytes +=3D scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes +=3D sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } netif_info(efx, hw, efx->net_dev, "MCDI RPC RESP:%s\n", buf); --=20 2.25.1