Skip to content

Commit 4920ee6

Browse files
Ansuelchanwoochoi
authored andcommitted
PM / devfreq: 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. Link: https://lore.kernel.org/all/20231024183016.14648-3-ansuelsmth@gmail.com/ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 08e23d0 commit 4920ee6

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

drivers/devfreq/devfreq.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ static ssize_t trans_stat_show(struct device *dev,
16971697
max_state = df->max_state;
16981698

16991699
if (max_state == 0)
1700-
return scnprintf(buf, PAGE_SIZE, "Not Supported.\n");
1700+
return sysfs_emit(buf, "Not Supported.\n");
17011701

17021702
mutex_lock(&df->lock);
17031703
if (!df->stop_polling &&
@@ -1707,47 +1707,44 @@ static ssize_t trans_stat_show(struct device *dev,
17071707
}
17081708
mutex_unlock(&df->lock);
17091709

1710-
len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n");
1711-
len += scnprintf(buf + len, PAGE_SIZE - len, " :");
1710+
len += sysfs_emit_at(buf, len, " From : To\n");
1711+
len += sysfs_emit_at(buf, len, " :");
17121712
for (i = 0; i < max_state; i++) {
17131713
if (len >= PAGE_SIZE - 1)
17141714
break;
1715-
len += scnprintf(buf + len, PAGE_SIZE - len, "%10lu",
1716-
df->freq_table[i]);
1715+
len += sysfs_emit_at(buf, len, "%10lu",
1716+
df->freq_table[i]);
17171717
}
1718+
17181719
if (len >= PAGE_SIZE - 1)
17191720
return PAGE_SIZE - 1;
1720-
1721-
len += scnprintf(buf + len, PAGE_SIZE - len, " time(ms)\n");
1721+
len += sysfs_emit_at(buf, len, " time(ms)\n");
17221722

17231723
for (i = 0; i < max_state; i++) {
17241724
if (len >= PAGE_SIZE - 1)
17251725
break;
1726-
if (df->freq_table[i] == df->previous_freq)
1727-
len += scnprintf(buf + len, PAGE_SIZE - len, "*");
1726+
if (df->freq_table[2] == df->previous_freq)
1727+
len += sysfs_emit_at(buf, len, "*");
17281728
else
1729-
len += scnprintf(buf + len, PAGE_SIZE - len, " ");
1729+
len += sysfs_emit_at(buf, len, " ");
17301730
if (len >= PAGE_SIZE - 1)
17311731
break;
1732-
1733-
len += scnprintf(buf + len, PAGE_SIZE - len, "%10lu:",
1734-
df->freq_table[i]);
1732+
len += sysfs_emit_at(buf, len, "%10lu:", df->freq_table[i]);
17351733
for (j = 0; j < max_state; j++) {
17361734
if (len >= PAGE_SIZE - 1)
17371735
break;
1738-
len += scnprintf(buf + len, PAGE_SIZE - len, "%10u",
1739-
df->stats.trans_table[(i * max_state) + j]);
1736+
len += sysfs_emit_at(buf, len, "%10u",
1737+
df->stats.trans_table[(i * max_state) + j]);
17401738
}
17411739
if (len >= PAGE_SIZE - 1)
17421740
break;
1743-
len += scnprintf(buf + len, PAGE_SIZE - len, "%10llu\n", (u64)
1744-
jiffies64_to_msecs(df->stats.time_in_state[i]));
1741+
len += sysfs_emit_at(buf, len, "%10llu\n", (u64)
1742+
jiffies64_to_msecs(df->stats.time_in_state[i]));
17451743
}
17461744

17471745
if (len < PAGE_SIZE - 1)
1748-
len += scnprintf(buf + len, PAGE_SIZE - len, "Total transition : %u\n",
1749-
df->stats.total_trans);
1750-
1746+
len += sysfs_emit_at(buf, len, "Total transition : %u\n",
1747+
df->stats.total_trans);
17511748
if (len >= PAGE_SIZE - 1) {
17521749
pr_warn_once("devfreq transition table exceeds PAGE_SIZE. Disabling\n");
17531750
return -EFBIG;

0 commit comments

Comments
 (0)