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

Jiri Slaby jirislaby at kernel.org
Sun Mar 16 23:21:23 PDT 2025


On 15. 03. 25, 7:15, xie.ludan at zte.com.cn wrote:
> From: XieLudan <xie.ludan at 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 at zte.com.cn>
> 
> ---
> 
>   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@kernel.org/

regards,
-- 
js
suse labs




More information about the linux-arm-kernel mailing list