Skip to content

Commit

Permalink
perf/core: Use sysfs_emit() instead of scnprintf()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
XieLudan authored and Ingo Molnar committed Mar 16, 2025
1 parent fd3f5d3 commit b6ecb57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit b6ecb57

Please sign in to comment.