Skip to contentSkip to conversation

arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()

PATCH In review Rujra Bhatt 2 participants 4 messages Jul 5, 2025 – Jul 22, 2025

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

PATCH 1/1 arc:kernel:perf_event.c : replaced sprintf with sysfs_emit()

Replaced sprintf() with sysfs_emit() in sysfs*_show() function in perf_event.c file to follow the kernel's guidlines from documentation/filesystems/sysfs.rst
This will improve consistency, safety, and makes it easier to maintain and update in future.

---
 arch/arc/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/perf_event.c +1 -1
index ed6d4f0cd621..424ec072c441 100644
@@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
 	struct perf_pmu_events_attr *pmu_attr;
 
 	pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
-	return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
+	return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
 }
 
 /*
Signature · 1 line
2.43.0
#1 lore raw

Hi,

Quoted 26 lines · Rujra Bhatt

Replaced sprintf() with sysfs_emit() in sysfs*_show() function in perf_event.c file to follow the kernel's guidelines from documentation/filesystems/sysfs.rst
This will improve consistency, safety, and makes it easier to maintain and update in future.

---
 arch/arc/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/perf_event.c +1 -2
index ed6d4f0cd621..424ec072c441 100644
@@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
        struct perf_pmu_events_attr *pmu_attr;
 
        pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
-       return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
+       return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
 }
 
 /*
--
Quoted 2 lines

2.43.0

Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly review it.

Thanking you,
regards,
Rujra Bhatt

#2 lore raw
Quoted 27 lines · Rujra Bhatt

Hi,

Quoted 24 lines · Rujra Bhatt

Replaced sprintf() with sysfs_emit() in sysfs*_show() function in perf_event.c file to follow the kernel's guidelines from documentation/filesystems/sysfs.rst
This will improve consistency, safety, and makes it easier to maintain and update in future.

---
 arch/arc/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/perf_event.c +1 -1
index ed6d4f0cd621..424ec072c441 100644
@@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
        struct perf_pmu_events_attr *pmu_attr;
 
        pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
-       return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
+       return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
 }
 
Quoted 7 lines
Quoted 4 lines
arch/arc/kernel/perf_event.c +0 -1
 /*
--

2.43.0

Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly review it.

Why is this required? There is no bug in the current code, so no need to change it at all. Please just use sysfs_emit() for new sysfs files, no need to churn the tree and change all existing entries, otherwise we would have done this a long time ago when we introduced these functions.

thanks,

greg k-h

#3 lore raw
Quoted 37 lines · Greg KH
Quoted 27 lines · Rujra Bhatt

Hi,

Quoted 24 lines · Rujra Bhatt

Replaced sprintf() with sysfs_emit() in sysfs*_show() function in perf_event.c file to follow the kernel's guidelines from documentation/filesystems/sysfs.rst
This will improve consistency, safety, and makes it easier to maintain and update in future.

---
 arch/arc/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/perf_event.c +1 -1
index ed6d4f0cd621..424ec072c441 100644
@@ -648,7 +648,7 @@ static ssize_t arc_pmu_events_sysfs_show(struct device *dev,
        struct perf_pmu_events_attr *pmu_attr;
 
        pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
-       return sprintf(page, "event=0x%04llx\n", pmu_attr->id);
+       return sysfs_emit(page, "event=0x%04llx\n", pmu_attr->id);
 }
 
Quoted 7 lines
Quoted 4 lines
arch/arc/kernel/perf_event.c +0 -1
 /*
--

2.43.0

Gentle reminder for the replacement of sprintf() with the sysfs_emit(), kindly review it.

Quoted 5 lines

Why is this required? There is no bug in the current code, so no need to change it at all. Please just use sysfs_emit() for new sysfs files, no need to churn the tree and change all existing entries, otherwise we would have done this a long time ago when we introduced these functions.

Hi Greg,
I appreciate your feedback.

I wanted to bring the formatting in line with the
latest guidance, especially since sysfs_emit() has become the recommended method for sysfs output. I see now, though, that I should restrict myself to using that helper only in the context of genuine bug fixes or in the course of adding features.
I'll make sure to only use sysfs_emit() for new sysfs entries or when modifying existing files for actual bugs or feature changes,
as per your guidance.

Thank you so much for pointing this out.

regards,
Rujra Bhatt