From: <xie.ludan@zte.com.cn>
To: <tglx@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <xu.xin16@zte.com.cn>,
<yang.yang29@zte.com.cn>
Subject: [PATCH linux-next] genirq: use sysfs_emit()/sysfs_emit_at() instead of scnprintf().
Date: Mon, 17 Mar 2025 14:54:56 +0800 (CST) [thread overview]
Message-ID: <20250317145456376WIxu0TMZrHMod4XZCbh2g@zte.com.cn> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 2052 bytes --]
From: XieLudan <xie.ludan@zte.com.cn>
Follow the advice in Documentation/filesystems/sysfs.rst: show() should
only use sysfs_emit() or sysfs_emit_at() when formatting the value to be
returned to user space.
Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
---
kernel/irq/irqdesc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 287830739783..8d1f4ecfe880 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -257,11 +257,11 @@ static ssize_t per_cpu_count_show(struct kobject *kobj,
for_each_possible_cpu(cpu) {
unsigned int c = irq_desc_kstat_cpu(desc, cpu);
- ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%u", p, c);
+ ret += sysfs_emit_at(buf, ret, "%s%u", p, c);
p = ",";
}
- ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
+ ret += sysfs_emit_at(buf, ret, "\n");
return ret;
}
IRQ_ATTR_RO(per_cpu_count);
@@ -274,7 +274,7 @@ static ssize_t chip_name_show(struct kobject *kobj,
raw_spin_lock_irq(&desc->lock);
if (desc->irq_data.chip && desc->irq_data.chip->name) {
- ret = scnprintf(buf, PAGE_SIZE, "%s\n",
+ ret = sysfs_emit(buf, "%s\n",
desc->irq_data.chip->name);
}
raw_spin_unlock_irq(&desc->lock);
@@ -337,7 +337,7 @@ static ssize_t name_show(struct kobject *kobj,
raw_spin_lock_irq(&desc->lock);
if (desc->name)
- ret = scnprintf(buf, PAGE_SIZE, "%s\n", desc->name);
+ ret = sysfs_emit(buf, "%s\n", desc->name);
raw_spin_unlock_irq(&desc->lock);
return ret;
@@ -354,14 +354,14 @@ static ssize_t actions_show(struct kobject *kobj,
raw_spin_lock_irq(&desc->lock);
for_each_action_of_desc(desc, action) {
- ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
+ ret += sysfs_emit_at(buf, ret, "%s%s",
p, action->name);
p = ",";
}
raw_spin_unlock_irq(&desc->lock);
if (ret)
- ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
+ ret += sysfs_emit_at(buf, ret, "\n");
return ret;
}
--
2.25.1
[-- Attachment #1.1.2: Type: text/html , Size: 3969 bytes --]
next reply other threads:[~2025-03-17 6:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 6:54 xie.ludan [this message]
2025-03-17 7:14 ` Jiri Slaby
2025-03-17 8:22 ` xie.ludan
2025-03-17 8:48 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250317145456376WIxu0TMZrHMod4XZCbh2g@zte.com.cn \
--to=xie.ludan@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=xu.xin16@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®