mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH linux-next] perf/core: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:17 xie.ludan
  2025-03-16 12:06 ` [tip: perf/core] perf/core: Use " tip-bot2 for XieLudan
  0 siblings, 1 reply; 2+ messages in thread
From: xie.ludan @ 2025-03-15  6:17 UTC (permalink / raw)
  To: peterz
  Cc: mingo, acme, namhyung, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, kan.liang, linux-perf-users,
	linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 1432 bytes --]

From: XieLudan <xie.ludan@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: XieLudan <xie.ludan@zte.com.cn>
---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 96f957035c6e..209250f4851a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11698,7 +11698,7 @@ static ssize_t nr_addr_filters_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
+	return sysfs_emit(page, "%d\n", pmu->nr_addr_filters);
 }
 DEVICE_ATTR_RO(nr_addr_filters);
 
@@ -11709,7 +11709,7 @@ type_show(struct device *dev, struct device_attribute *attr, char *page)
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->type);
+	return sysfs_emit(page, "%d\n", pmu->type);
 }
 static DEVICE_ATTR_RO(type);
 
@@ -11720,7 +11720,7 @@ perf_event_mux_interval_ms_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->hrtimer_interval_ms);
+	return sysfs_emit(page, "%d\n", pmu->hrtimer_interval_ms);
 }
 
 static DEFINE_MUTEX(mux_interval_mutex);
-- 
2.25.1

[-- Attachment #1.1.2: Type: text/html , Size: 2600 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip: perf/core] perf/core: Use sysfs_emit() instead of scnprintf()
  2025-03-15  6:17 [PATCH linux-next] perf/core: use sysfs_emit() instead of scnprintf() xie.ludan
@ 2025-03-16 12:06 ` tip-bot2 for XieLudan
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for XieLudan @ 2025-03-16 12:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: XieLudan, Ingo Molnar, Peter Zijlstra, x86, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     b6ecb57f1fec114cfa19b1bf06f25f904ca928f9
Gitweb:        https://git.kernel.org/tip/b6ecb57f1fec114cfa19b1bf06f25f904ca928f9
Author:        XieLudan <xie.ludan@zte.com.cn>
AuthorDate:    Sat, 15 Mar 2025 14:17:38 +08:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Sun, 16 Mar 2025 12:38:27 +01:00

perf/core: Use sysfs_emit() instead of scnprintf()

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

No change in functionality intended.

[ mingo: Updated the changelog ]

Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250315141738452lXIH39UJAXlCmcATCzcBv@zte.com.cn
---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index e7d0b05..2533fc3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11713,7 +11713,7 @@ static ssize_t nr_addr_filters_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
+	return sysfs_emit(page, "%d\n", pmu->nr_addr_filters);
 }
 DEVICE_ATTR_RO(nr_addr_filters);
 
@@ -11724,7 +11724,7 @@ type_show(struct device *dev, struct device_attribute *attr, char *page)
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->type);
+	return sysfs_emit(page, "%d\n", pmu->type);
 }
 static DEVICE_ATTR_RO(type);
 
@@ -11735,7 +11735,7 @@ perf_event_mux_interval_ms_show(struct device *dev,
 {
 	struct pmu *pmu = dev_get_drvdata(dev);
 
-	return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->hrtimer_interval_ms);
+	return sysfs_emit(page, "%d\n", pmu->hrtimer_interval_ms);
 }
 
 static DEFINE_MUTEX(mux_interval_mutex);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-16 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-15  6:17 [PATCH linux-next] perf/core: use sysfs_emit() instead of scnprintf() xie.ludan
2025-03-16 12:06 ` [tip: perf/core] perf/core: Use " tip-bot2 for XieLudan

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

all inboxes | Powered by JetHome®