* [PATCH] cpufreq: governor: Use sysfs_emit in sysfs show functions
@ 2026-02-23 21:03 Thorsten Blum
2026-03-03 4:12 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-02-23 21:03 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar; +Cc: Thorsten Blum, linux-pm, linux-kernel
Replace sprintf() with sysfs_emit() in sysfs show functions.
sysfs_emit() is preferred for formatting sysfs output because it
provides safer bounds checking. No functional changes.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/cpufreq/cpufreq_governor.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 168c23fd7fca..732fd4d1a803 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -21,6 +21,7 @@
#include <linux/kernel_stat.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/sysfs.h>
/* Ondemand Sampling types */
enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
@@ -57,7 +58,7 @@ static ssize_t file_name##_show \
{ \
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \
- return sprintf(buf, "%u\n", tuners->file_name); \
+ return sysfs_emit(buf, "%u\n", tuners->file_name); \
}
#define gov_show_one_common(file_name) \
@@ -65,7 +66,7 @@ static ssize_t file_name##_show \
(struct gov_attr_set *attr_set, char *buf) \
{ \
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
- return sprintf(buf, "%u\n", dbs_data->file_name); \
+ return sysfs_emit(buf, "%u\n", dbs_data->file_name); \
}
#define gov_attr_ro(_name) \
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: governor: Use sysfs_emit in sysfs show functions
2026-02-23 21:03 [PATCH] cpufreq: governor: Use sysfs_emit in sysfs show functions Thorsten Blum
@ 2026-03-03 4:12 ` Viresh Kumar
2026-03-06 18:34 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2026-03-03 4:12 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Rafael J. Wysocki, linux-pm, linux-kernel
On 23-02-26, 22:03, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in sysfs show functions.
> sysfs_emit() is preferred for formatting sysfs output because it
> provides safer bounds checking. No functional changes.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/cpufreq/cpufreq_governor.h | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq: governor: Use sysfs_emit in sysfs show functions
2026-03-03 4:12 ` Viresh Kumar
@ 2026-03-06 18:34 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2026-03-06 18:34 UTC (permalink / raw)
To: Viresh Kumar, Thorsten Blum; +Cc: linux-pm, linux-kernel
On Tue, Mar 3, 2026 at 5:12 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 23-02-26, 22:03, Thorsten Blum wrote:
> > Replace sprintf() with sysfs_emit() in sysfs show functions.
> > sysfs_emit() is preferred for formatting sysfs output because it
> > provides safer bounds checking. No functional changes.
> >
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> > drivers/cpufreq/cpufreq_governor.h | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Applied as 7.1 material, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-06 18:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 21:03 [PATCH] cpufreq: governor: Use sysfs_emit in sysfs show functions Thorsten Blum
2026-03-03 4:12 ` Viresh Kumar
2026-03-06 18:34 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox