From patchwork Thu Dec 8 07:23:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 31187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp54859wrr; Wed, 7 Dec 2022 23:37:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UQjZZBl61qgo1iGjmAMmIv1gOrxtabIqav5MOE/7CExE9cDuzIKsd1/ZbrHdWYlR87YU3 X-Received: by 2002:aa7:da4d:0:b0:46b:4156:bf29 with SMTP id w13-20020aa7da4d000000b0046b4156bf29mr39167431eds.246.1670485077948; Wed, 07 Dec 2022 23:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670485077; cv=none; d=google.com; s=arc-20160816; b=KmtHdh3zxbORZrerFROuIUl4UrsmfY1e1AGGrjXLL8KQtiAZj5TFuOjqWpF6/+nmA4 xXzctidsSHuzI15DLeLj2+zDZ+G58+pO6EIdTpx6OkXcAXnDA2V5qqWr9+tq5B5sMOUA OqbGT9bCbbd0uFREHz+bT8OUuGtDeIfQi/HFWUWbi9GlRGR78I3WE2/mdqaqCxJIO3p7 YYyNq/Qs6qOkJICRDBs1VH+RW3D5eRuHxRZWPZnDUVYVSViDbWjPGnZs326sOyqNMu+5 j6ZItkqFJfVjUh3Z+7l/+erDPju/oBkPJ1bvCyoFr7nl1kg3F1JfYFWWvyGUNCSMLfs9 53JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=p2hOXK4We8uzkP5ghl35aXZEXZDHhxLTNOJO64mzAnU=; b=OcimTnbi/z7fKjKAHpxR/b0/cQcqB7veKpGXq/dgdunUDAuf0tNztGu2AwWVlyu365 y3ngl24somNuDAdubo5yvXo5CgtKn4Itiq3l6ilLUEcndAny8MB68osNQXKg4TYzKBhp 6bU1ohaAKIUPf4EXlN482KMBpDfbtzx2sU1THZYEevmBhNLip99s+osQ8oYiTmgHQp2A RJ/C7O9VBZyfllT2/Vb/HDj1YhVbzq6VYrWReIeVHEJN2gUisYmOvAsR9Copy0+xg6p7 7pea0mzUDyZr9mD8hW/x0j+UDbpJi3mXK07j0qw2456s9dWyErstY4RHfSTCZ+j+9Sr2 eXyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb20-20020a1709071c9400b007ae26c753edsi20850119ejc.52.2022.12.07.23.37.19; Wed, 07 Dec 2022 23:37:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbiLHHXh (ORCPT + 99 others); Thu, 8 Dec 2022 02:23:37 -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?q?=5BPATCH_net-next=5D_sfc=3A_Convert_to_use_sysfs=5Femit?= =?utf-8?q?=5Fat=28=29_API?= 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751630561053135662?= X-GMAIL-MSGID: =?utf-8?q?1751630561053135662?= 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/mcdi.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 = 0; i < hdr_len / 4 && bytes < PAGE_SIZE; i++) - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(hdr[i].u32[0])); + bytes += sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr[i].u32[0])); for (i = 0; i < inlen / 4 && bytes < PAGE_SIZE; i++) - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(inbuf[i].u32[0])); + bytes += 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 = 0; i < hdr_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes += sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } for (i = 0; i < data_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len + (i * 4), 4); - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes += 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/sfc/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 = 0; i < hdr_len / 4 && bytes < PAGE_SIZE; i++) - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(hdr[i].u32[0])); + bytes += sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr[i].u32[0])); for (i = 0; i < inlen / 4 && bytes < PAGE_SIZE; i++) - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", - le32_to_cpu(inbuf[i].u32[0])); + bytes += 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 = 0; i < hdr_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes += sysfs_emit_at(buf, bytes, " %08x", le32_to_cpu(hdr.u32[0])); } for (i = 0; i < data_len && bytes < PAGE_SIZE; i++) { efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len + (i * 4), 4); - bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, - " %08x", le32_to_cpu(hdr.u32[0])); + bytes += 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);