[PATCH] intel_th: msu: use sysfs_emit_at() instead of scnprintf()

tang.dongxing@zte.com.cn posted 1 patch 9 months ago
drivers/hwtracing/intel_th/msu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] intel_th: msu: use sysfs_emit_at() instead of scnprintf()
Posted by tang.dongxing@zte.com.cn 9 months ago
From: TangDongxing <tang.dongxing@zte.com.cn>

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>
---
 drivers/hwtracing/intel_th/msu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index bf99d79a4192..eb474e9a9645 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1983,15 +1983,15 @@ nr_pages_show(struct device *dev, struct device_attribute *attr, char *buf)
 	mutex_lock(&msc->buf_mutex);

 	if (msc->mode == MSC_MODE_SINGLE)
-		count = scnprintf(buf, PAGE_SIZE, "%ld\n", msc->nr_pages);
+		count = sysfs_emit(buf, "%ld\n", msc->nr_pages);
 	else if (msc->mode == MSC_MODE_MULTI) {
 		list_for_each_entry(win, &msc->win_list, entry) {
-			count += scnprintf(buf + count, PAGE_SIZE - count,
+			count += sysfs_emit_at(buf, count,
 					   "%d%c", win->nr_blocks,
 					   msc_is_last_win(win) ? '\n' : ',');
 		}
 	} else {
-		count = scnprintf(buf, PAGE_SIZE, "unsupported\n");
+		count = sysfs_emit(buf, "unsupported\n");
 	}

 	mutex_unlock(&msc->buf_mutex);
-- 
2.25.1