netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <ye.xingchen@zte.com.cn>
To: <kuba@kernel.org>
Cc: <ecree.xilinx@gmail.com>, <habetsm.xilinx@gmail.com>,
	<davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
	<wangxiang@cdjrlc.com>, <dossche.niels@gmail.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH net-next] sfc: Convert to use sysfs_emit_at() API
Date: Thu, 8 Dec 2022 15:23:27 +0800 (CST)	[thread overview]
Message-ID: <202212081523277319144@zte.com.cn> (raw)

From: ye xingchen <ye.xingchen@zte.com.cn>

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 <ye.xingchen@zte.com.cn>
---
 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);
-- 
2.25.1

             reply	other threads:[~2022-12-08  7:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08  7:23 ye.xingchen [this message]
2022-12-08  8:24 ` [PATCH net-next] sfc: Convert to use sysfs_emit_at() API Martin Habets

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202212081523277319144@zte.com.cn \
    --to=ye.xingchen@zte.com.cn \
    --cc=davem@davemloft.net \
    --cc=dossche.niels@gmail.com \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=habetsm.xilinx@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wangxiang@cdjrlc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).