2022-12-08 10:10:25

by ye.xingchen

[permalink] [raw]
Subject: [PATCH] thermal: Convert to use sysfs_emit_at() API

From: ye xingchen <[email protected]>

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 <[email protected]>
---
drivers/thermal/thermal_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index f17ab2316dbd..91d40ce62c92 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -229,10 +229,9 @@ int thermal_build_list_of_policies(char *buf)
mutex_lock(&thermal_governor_lock);

list_for_each_entry(pos, &thermal_governor_list, governor_list) {
- count += scnprintf(buf + count, PAGE_SIZE - count, "%s ",
- pos->name);
+ count += sysfs_emit_at(buf, count, "%s ", pos->name);
}
- count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
+ count += sysfs_emit_at(buf, count, "\n");

mutex_unlock(&thermal_governor_lock);

--
2.25.1


2022-12-08 13:08:31

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] thermal: Convert to use sysfs_emit_at() API

On Thu, Dec 8, 2022 at 10:06 AM <[email protected]> wrote:
>
> From: ye xingchen <[email protected]>
>
> 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 <[email protected]>

Again, please resend this after 6.2-rc1 is out, thanks!

> ---
> drivers/thermal/thermal_core.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index f17ab2316dbd..91d40ce62c92 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -229,10 +229,9 @@ int thermal_build_list_of_policies(char *buf)
> mutex_lock(&thermal_governor_lock);
>
> list_for_each_entry(pos, &thermal_governor_list, governor_list) {
> - count += scnprintf(buf + count, PAGE_SIZE - count, "%s ",
> - pos->name);
> + count += sysfs_emit_at(buf, count, "%s ", pos->name);
> }
> - count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
> + count += sysfs_emit_at(buf, count, "\n");
>
> mutex_unlock(&thermal_governor_lock);
>
> --
> 2.25.1