* [PATCH] firmware: imx: scu-irq: accumulate wakeup sources via sysfs_emit_at()
@ 2026-05-15 17:50 Stepan Ionichev
0 siblings, 0 replies; only message in thread
From: Stepan Ionichev @ 2026-05-15 17:50 UTC (permalink / raw)
To: Frank.Li
Cc: s.hauer, kernel, festevam, shawnguo, gregkh, hcazarim, imx,
linux-arm-kernel, linux-kernel, sozdayvek
wakeup_source_show() walks all IMX_SC_IRQ_NUM_GROUP groups and, for
every group with a wakeup_src set, writes a line into the sysfs
output buffer:
for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) {
if (!scu_irq_wakeup[i].wakeup_src)
continue;
if (scu_irq_wakeup[i].valid)
sprintf(buf, "Wakeup source group = %d, ...", ...);
else
sprintf(buf, "Spurious SCU wakeup, group = %d, ...", ...);
}
return strlen(buf);
Each iteration calls sprintf(buf, ...) starting at buf[0], so the
previous group's line is overwritten. When several groups have
wakeup_src set simultaneously, userspace reading
/sys/.../wakeup_src sees only the last group reported, not the full
set. The trailing return strlen(buf) reports only that last line's
length for the same reason.
sprintf() also has no buffer length argument; sysfs callbacks must
not write past PAGE_SIZE.
Convert to sysfs_emit_at() with a running offset so each group's
line is appended after the previous one, and bound the writes to
the PAGE_SIZE sysfs limit. Return the accumulated length directly
instead of strlen(buf).
Fixes: c081197a33a2 ("firmware: imx: scu-irq: support identifying SCU wakeup source from sysfs")
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
drivers/firmware/imx/imx-scu-irq.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-scu-irq.c
index a68d38f89..d1fb20d95 100644
--- a/drivers/firmware/imx/imx-scu-irq.c
+++ b/drivers/firmware/imx/imx-scu-irq.c
@@ -179,6 +179,7 @@ static void imx_scu_irq_callback(struct mbox_client *c, void *msg)
static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
+ ssize_t len = 0;
int i;
for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) {
@@ -186,14 +187,16 @@ static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attribute *a
continue;
if (scu_irq_wakeup[i].valid)
- sprintf(buf, "Wakeup source group = %d, irq = 0x%x\n",
+ len += sysfs_emit_at(buf, len,
+ "Wakeup source group = %d, irq = 0x%x\n",
i, scu_irq_wakeup[i].wakeup_src);
else
- sprintf(buf, "Spurious SCU wakeup, group = %d, irq = 0x%x\n",
+ len += sysfs_emit_at(buf, len,
+ "Spurious SCU wakeup, group = %d, irq = 0x%x\n",
i, scu_irq_wakeup[i].wakeup_src);
}
- return strlen(buf);
+ return len;
}
int imx_scu_enable_general_irq_channel(struct device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-15 17:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 17:50 [PATCH] firmware: imx: scu-irq: accumulate wakeup sources via sysfs_emit_at() Stepan Ionichev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox