sfc: Convert to use sysfs_emit_at() API
Subsystems (3)
PATCH 1/1 sfc: Convert to use sysfs_emit_at() API
From: ye xingchen <[email protected]>
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 <[email protected]>
--- drivers/net/ethernet/sfc/mcdi.c | 14 ++++---------- drivers/net/ethernet/sfc/siena/mcdi.c | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-)
drivers/net/ethernet/sfc/mcdi.c +4 -10
@@ -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);
drivers/net/ethernet/sfc/siena/mcdi.c +4 -10
@@ -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);
Signature · 1 line
2.25.1
Quoted 5 lines · On Thu, Dec 08, 2022 at 03:23:27PM +0800, [email protected] wrote:
From: ye xingchen <[email protected]>
Follow the advice of the
Documentation/filesystems/sysfs.rstandshow()should only usesysfs_emit()orsysfs_emit_at()when formatting the value to be returned to user space.
That advice is for sysfs but this output is going into dmesg. So it does not apply here.
Martin
Quoted 86 lines
Signed-off-by ye xingchen <[email protected]>--- drivers/net/ethernet/sfc/mcdi.c | 14 ++++---------- drivers/net/ethernet/sfc/siena/mcdi.c | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-)drivers/net/ethernet/sfc/mcdi.c +4
-10@@ -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);drivers/net/ethernet/sfc/siena/mcdi.c +4
-10@@ -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);Signature · 1 line
2.25.1