Skip to contentSkip to conversation

perf/x86/amd: replace snprintf with sysfs_emit helper function

PATCH New Paulo Miguel Almeida 1 participant 1 message Oct 19, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/x86/amd: replace snprintf with sysfs_emit helper function

sysfs_emit() helper function should be used when formatting the value to be returned to user space as per the documentation. No need to replicate logic in sysfs .show() callbacks.

This patch replaces open-coded sysfs_emit() logic sysfs .show() callbacks.

---
 arch/x86/events/amd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/amd/core.c +1 -1
index b4a1a2576510..bbada8e3e491 100644
@@ -1346,7 +1346,7 @@ static ssize_t branches_show(struct device *cdev,
 			      struct device_attribute *attr,
 			      char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
+	return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
 }
 
 static DEVICE_ATTR_RO(branches);
Signature · 1 line
2.47.0