linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: Convert to use sysfs_emit_at() API
@ 2022-12-08  9:06 ye.xingchen
  2022-12-08 11:51 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: ye.xingchen @ 2022-12-08  9:06 UTC (permalink / raw)
  To: rafael; +Cc: daniel.lezcano, amitk, rui.zhang, linux-pm, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

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>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal: Convert to use sysfs_emit_at() API
  2022-12-08  9:06 ye.xingchen
@ 2022-12-08 11:51 ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-12-08 11:51 UTC (permalink / raw)
  To: ye.xingchen
  Cc: rafael, daniel.lezcano, amitk, rui.zhang, linux-pm, linux-kernel

On Thu, Dec 8, 2022 at 10:06 AM <ye.xingchen@zte.com.cn> wrote:
>
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> 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>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] thermal: Convert to use sysfs_emit_at() API
@ 2023-01-17  2:40 ye.xingchen
  2023-02-09 19:42 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: ye.xingchen @ 2023-01-17  2:40 UTC (permalink / raw)
  To: rafael; +Cc: daniel.lezcano, amitk, rui.zhang, linux-pm, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

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>
---
 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 d9a3d9566d73..5ffc7006cce4 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal: Convert to use sysfs_emit_at() API
  2023-01-17  2:40 [PATCH] thermal: Convert to use sysfs_emit_at() API ye.xingchen
@ 2023-02-09 19:42 ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-02-09 19:42 UTC (permalink / raw)
  To: ye.xingchen
  Cc: rafael, daniel.lezcano, amitk, rui.zhang, linux-pm, linux-kernel

On Tue, Jan 17, 2023 at 3:40 AM <ye.xingchen@zte.com.cn> wrote:
>
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> 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>
> ---
>  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 d9a3d9566d73..5ffc7006cce4 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);
>
> --

Applied as 6.3 material, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-09 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17  2:40 [PATCH] thermal: Convert to use sysfs_emit_at() API ye.xingchen
2023-02-09 19:42 ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2022-12-08  9:06 ye.xingchen
2022-12-08 11:51 ` 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;
as well as URLs for NNTP newsgroup(s).