Skip to content

Commit 7ed40bc

Browse files
ye xingchenrafaeljw
authored andcommitted
cpufreq: stats: Convert to use sysfs_emit_at() API
Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 4420463 commit 7ed40bc

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

drivers/cpufreq/cpufreq_stats.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,23 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
128128
ssize_t len = 0;
129129
int i, j, count;
130130

131-
len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n");
132-
len += scnprintf(buf + len, PAGE_SIZE - len, " : ");
131+
len += sysfs_emit_at(buf, len, " From : To\n");
132+
len += sysfs_emit_at(buf, len, " : ");
133133
for (i = 0; i < stats->state_num; i++) {
134134
if (len >= PAGE_SIZE)
135135
break;
136-
len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
137-
stats->freq_table[i]);
136+
len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]);
138137
}
139138
if (len >= PAGE_SIZE)
140139
return PAGE_SIZE;
141140

142-
len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
141+
len += sysfs_emit_at(buf, len, "\n");
143142

144143
for (i = 0; i < stats->state_num; i++) {
145144
if (len >= PAGE_SIZE)
146145
break;
147146

148-
len += scnprintf(buf + len, PAGE_SIZE - len, "%9u: ",
149-
stats->freq_table[i]);
147+
len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]);
150148

151149
for (j = 0; j < stats->state_num; j++) {
152150
if (len >= PAGE_SIZE)
@@ -157,11 +155,11 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
157155
else
158156
count = stats->trans_table[i * stats->max_state + j];
159157

160-
len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", count);
158+
len += sysfs_emit_at(buf, len, "%9u ", count);
161159
}
162160
if (len >= PAGE_SIZE)
163161
break;
164-
len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
162+
len += sysfs_emit_at(buf, len, "\n");
165163
}
166164

167165
if (len >= PAGE_SIZE) {

0 commit comments

Comments
 (0)