linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fpga: use sysfs_emit() to instead of scnprintf()
@ 2022-12-01  2:17 ye.xingchen
  0 siblings, 0 replies; only message in thread
From: ye.xingchen @ 2022-12-01  2:17 UTC (permalink / raw)
  To: hao.wu; +Cc: trix, mdf, yilun.xu, linux-fpga, linux-kernel

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

Replace the open-code with sysfs_emit() to simplify the code.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/fpga/dfl-afu-main.c | 4 ++--
 drivers/fpga/dfl-fme-main.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 7f621e96d3b8..454fd4853000 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -155,7 +155,7 @@ id_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	int id = port_get_id(to_platform_device(dev));

-	return scnprintf(buf, PAGE_SIZE, "%d\n", id);
+	return sysfs_emit(buf, "%d\n", id);
 }
 static DEVICE_ATTR_RO(id);

@@ -472,7 +472,7 @@ afu_id_show(struct device *dev, struct device_attribute *attr, char *buf)
 	guidh = readq(base + GUID_H);
 	mutex_unlock(&pdata->lock);

-	return scnprintf(buf, PAGE_SIZE, "%016llx%016llx\n", guidh, guidl);
+	return sysfs_emit(buf, "%016llx%016llx\n", guidh, guidl);
 }
 static DEVICE_ATTR_RO(afu_id);

diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index 77ea04d4edbe..50e1ed69b811 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -34,7 +34,7 @@ static ssize_t ports_num_show(struct device *dev,

 	v = readq(base + FME_HDR_CAP);

-	return scnprintf(buf, PAGE_SIZE, "%u\n",
+	return sysfs_emit(buf, "%u\n",
 			 (unsigned int)FIELD_GET(FME_CAP_NUM_PORTS, v));
 }
 static DEVICE_ATTR_RO(ports_num);
@@ -53,7 +53,7 @@ static ssize_t bitstream_id_show(struct device *dev,

 	v = readq(base + FME_HDR_BITSTREAM_ID);

-	return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v);
+	return sysfs_emit(buf, "0x%llx\n", (unsigned long long)v);
 }
 static DEVICE_ATTR_RO(bitstream_id);

@@ -71,7 +71,7 @@ static ssize_t bitstream_metadata_show(struct device *dev,

 	v = readq(base + FME_HDR_BITSTREAM_MD);

-	return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v);
+	return sysfs_emit(buf, "0x%llx\n", (unsigned long long)v);
 }
 static DEVICE_ATTR_RO(bitstream_metadata);

-- 
2.25.1

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

only message in thread, other threads:[~2022-12-01  2:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01  2:17 [PATCH] fpga: use sysfs_emit() to instead of scnprintf() ye.xingchen

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).