[PATCH] PM: wakeup: Delete space in the end of string shown by pm_show_wakelocks()

Zijun Hu posted 1 patch 9 months, 1 week ago
kernel/power/wakelock.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] PM: wakeup: Delete space in the end of string shown by pm_show_wakelocks()
Posted by Zijun Hu 9 months, 1 week ago
From: Zijun Hu <quic_zijuhu@quicinc.com>

pm_show_wakelocks() is called to generate a string when showing attributes
/sys/power/wake_(lock|unlock), but the string ends with an unwanted space
the space was added back by mistake by commit c9d967b2ce40
("PM: wakeup: simplify the output logic of pm_show_wakelocks()").

Remove the unwanted space.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 kernel/power/wakelock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 52571dcad768b988eaadbd3ce98a4ac42dd2f7dd..4e941999a53ba69410f4526d5d55c32312c36140 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -49,6 +49,9 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active)
 			len += sysfs_emit_at(buf, len, "%s ", wl->name);
 	}
 
+	if (len > 0)
+		--len;
+
 	len += sysfs_emit_at(buf, len, "\n");
 
 	mutex_unlock(&wakelocks_lock);

---
base-commit: 393d0c54cae31317deaa9043320c5fd9454deabc
change-id: 20250505-fix_power-a443c1a4399f

Best regards,
-- 
Zijun Hu <quic_zijuhu@quicinc.com>
Re: [PATCH] PM: wakeup: Delete space in the end of string shown by pm_show_wakelocks()
Posted by Rafael J. Wysocki 9 months ago
On Mon, May 5, 2025 at 11:27 AM Zijun Hu <zijun_hu@icloud.com> wrote:
>
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> pm_show_wakelocks() is called to generate a string when showing attributes
> /sys/power/wake_(lock|unlock), but the string ends with an unwanted space
> the space was added back by mistake by commit c9d967b2ce40
> ("PM: wakeup: simplify the output logic of pm_show_wakelocks()").
>
> Remove the unwanted space.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  kernel/power/wakelock.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
> index 52571dcad768b988eaadbd3ce98a4ac42dd2f7dd..4e941999a53ba69410f4526d5d55c32312c36140 100644
> --- a/kernel/power/wakelock.c
> +++ b/kernel/power/wakelock.c
> @@ -49,6 +49,9 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active)
>                         len += sysfs_emit_at(buf, len, "%s ", wl->name);
>         }
>
> +       if (len > 0)
> +               --len;
> +
>         len += sysfs_emit_at(buf, len, "\n");
>
>         mutex_unlock(&wakelocks_lock);
>
> ---

Applied as 6.16 material, thanks!