public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: be2iscsi: Convert to use sysfs_emit_at() API
@ 2022-12-08  8:21 ye.xingchen
  0 siblings, 0 replies; only message in thread
From: ye.xingchen @ 2022-12-08  8:21 UTC (permalink / raw)
  To: martin.petersen; +Cc: ketan.mukadam, jejb, linux-scsi, linux-kernel

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/scsi/be2iscsi/be_mgmt.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 4e899ec1477d..bf39140250bc 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1185,12 +1185,10 @@ beiscsi_active_session_disp(struct device *dev, struct device_attribute *attr,
 		if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
 			avlbl_cids = BEISCSI_ULP_AVLBL_CID(phba, ulp_num);
 			total_cids = BEISCSI_GET_CID_COUNT(phba, ulp_num);
-			len += scnprintf(buf+len, PAGE_SIZE - len,
-					 "ULP%d : %d\n", ulp_num,
-					 (total_cids - avlbl_cids));
+			len += sysfs_emit_at(buf, len, "ULP%d : %d\n",
+					     ulp_num, (total_cids - avlbl_cids));
 		} else
-			len += scnprintf(buf+len, PAGE_SIZE - len,
-					 "ULP%d : %d\n", ulp_num, 0);
+			len += sysfs_emit_at(buf, len, "ULP%d : %d\n", ulp_num, 0);
 	}

 	return len;
@@ -1215,12 +1213,10 @@ beiscsi_free_session_disp(struct device *dev, struct device_attribute *attr,

 	for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
 		if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported))
-			len += scnprintf(buf+len, PAGE_SIZE - len,
-					 "ULP%d : %d\n", ulp_num,
-					 BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
+			len += sysfs_emit_at(buf, len, "ULP%d : %d\n", ulp_num,
+					     BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
 		else
-			len += scnprintf(buf+len, PAGE_SIZE - len,
-					 "ULP%d : %d\n", ulp_num, 0);
+			len += sysfs_emit_at(buf, len, "ULP%d : %d\n", ulp_num, 0);
 	}

 	return len;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-08  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-08  8:21 [PATCH] scsi: be2iscsi: Convert to use sysfs_emit_at() API ye.xingchen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox