Re: [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().

From: Jiri Slaby
Date: Mon Mar 17 2025 - 02:21:35 EST


On 15. 03. 25, 7:15, xie.ludan@xxxxxxxxxx wrote:
From: XieLudan <xie.ludan@xxxxxxxxxx>


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

---

 sound/soc/fsl/imx-audmux.c | 26 +++++++++++---------------

 1 file changed, 11 insertions(+), 15 deletions(-)


diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c

index cc2918ee2cf5..6062503d3543 100644

--- a/sound/soc/fsl/imx-audmux.c

+++ b/sound/soc/fsl/imx-audmux.c

@@ -77,45 +77,41 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,

ret = sysfs_emit(buf, "PDCR: %08x\nPTCR: %08x\n", pdcr, ptcr);

if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR)

-ret += scnprintf(buf + ret, PAGE_SIZE - ret,

+ret += sysfs_emit(buf + ret,

This is wrong too [1].

[1] https://lore.kernel.org/all/9c552d9a-2d46-4069-a9c4-35fab857bfc3@xxxxxxxxxx/

regards,
--
js
suse labs