lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250315141529150fbawTX2YISM8pAvBtAksn@zte.com.cn>
Date: Sat, 15 Mar 2025 14:15:29 +0800 (CST)
From: <xie.ludan@....com.cn>
To: <xiubo.lee@...il.com>
Cc: <shengjiu.wang@...il.com>, <festevam@...il.com>, <nicoleotsuka@...il.com>,
        <lgirdwood@...il.com>, <broonie@...nel.org>, <perex@...ex.cz>,
        <tiwai@...e.com>, <shawnguo@...nel.org>, <s.hauer@...gutronix.de>,
        <kernel@...gutronix.de>, <linux-sound@...r.kernel.org>,
        <linuxppc-dev@...ts.ozlabs.org>, <imx@...ts.linux.dev>,
        <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().

From: XieLudan <xie.ludan@....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@....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,
 				"TxFS output from %s, ",
 				audmux_port_string((ptcr >> 27) & 0x7));
 	else
-		ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+		ret += sysfs_emit(buf + ret,
 				"TxFS input, ");
 
 	if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR)
-		ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+		ret += sysfs_emit(buf + ret,
 				"TxClk output from %s",
 				audmux_port_string((ptcr >> 22) & 0x7));
 	else
-		ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-				"TxClk input");
+		ret += sysfs_emit(buf + ret, "TxClk input");
 
-	ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
+	ret += sysfs_emit(buf + ret, "\n");
 
 	if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) {
-		ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-				"Port is symmetric");
+		ret += sysfs_emit(buf + ret, "Port is symmetric");
 	} else {
 		if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR)
-			ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+			ret += sysfs_emit(buf + ret,
 					"RxFS output from %s, ",
 					audmux_port_string((ptcr >> 17) & 0x7));
 		else
-			ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-					"RxFS input, ");
+			ret += sysfs_emit(buf + ret, "RxFS input, ");
 
 		if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR)
-			ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+			ret += sysfs_emit(buf + ret,
 					"RxClk output from %s",
 					audmux_port_string((ptcr >> 12) & 0x7));
 		else
-			ret += scnprintf(buf + ret, PAGE_SIZE - ret,
-					"RxClk input");
+			ret += sysfs_emit(buf + ret, "RxClk input");
 	}
 
-	ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+	ret += sysfs_emit(buf + ret,
 			"\nData received from %s\n",
 			audmux_port_string((pdcr >> 13) & 0x7));
 
-- 
2.25.1
<div class="zcontentRow"><p><span style="font-family: Arial, Helvetica, &quot;Microsoft Yahei&quot;, sans-serif; background-color: rgb(255, 255, 255);">From: XieLudan &lt;xie.ludan@....com.cn&gt;</span></p><p><br></p><p>Follow the advice in Documentation/filesystems/sysfs.rst:</p><p>show() should only use sysfs_emit() or sysfs_emit_at() when formatting</p><p>the value to be returned to user space.</p><p><br></p><p>Signed-off-by: XieLudan &lt;xie.ludan@....com.cn&gt;</p><p>---</p><p>&nbsp;sound/soc/fsl/imx-audmux.c | 26 +++++++++++---------------</p><p>&nbsp;1 file changed, 11 insertions(+), 15 deletions(-)</p><p><br></p><p>diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c</p><p>index cc2918ee2cf5..6062503d3543 100644</p><p>--- a/sound/soc/fsl/imx-audmux.c</p><p>+++ b/sound/soc/fsl/imx-audmux.c</p><p>@@ -77,45 +77,41 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,</p><p>&nbsp;<span style="white-space:pre">	</span>ret = sysfs_emit(buf, "PDCR: %08x\nPTCR: %08x\n", pdcr, ptcr);</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>if (ptcr &amp; IMX_AUDMUX_V2_PTCR_TFSDIR)</p><p>-<span style="white-space:pre">		</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">		</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">				</span>"TxFS output from %s, ",</p><p>&nbsp;<span style="white-space:pre">				</span>audmux_port_string((ptcr &gt;&gt; 27) &amp; 0x7));</p><p>&nbsp;<span style="white-space:pre">	</span>else</p><p>-<span style="white-space:pre">		</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">		</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">				</span>"TxFS input, ");</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>if (ptcr &amp; IMX_AUDMUX_V2_PTCR_TCLKDIR)</p><p>-<span style="white-space:pre">		</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">		</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">				</span>"TxClk output from %s",</p><p>&nbsp;<span style="white-space:pre">				</span>audmux_port_string((ptcr &gt;&gt; 22) &amp; 0x7));</p><p>&nbsp;<span style="white-space:pre">	</span>else</p><p>-<span style="white-space:pre">		</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>-<span style="white-space:pre">				</span>"TxClk input");</p><p>+<span style="white-space:pre">		</span>ret += sysfs_emit(buf + ret, "TxClk input");</p><p>&nbsp;</p><p>-<span style="white-space:pre">	</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");</p><p>+<span style="white-space:pre">	</span>ret += sysfs_emit(buf + ret, "\n");</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">	</span>if (ptcr &amp; IMX_AUDMUX_V2_PTCR_SYN) {</p><p>-<span style="white-space:pre">		</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>-<span style="white-space:pre">				</span>"Port is symmetric");</p><p>+<span style="white-space:pre">		</span>ret += sysfs_emit(buf + ret, "Port is symmetric");</p><p>&nbsp;<span style="white-space:pre">	</span>} else {</p><p>&nbsp;<span style="white-space:pre">		</span>if (ptcr &amp; IMX_AUDMUX_V2_PTCR_RFSDIR)</p><p>-<span style="white-space:pre">			</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">			</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">					</span>"RxFS output from %s, ",</p><p>&nbsp;<span style="white-space:pre">					</span>audmux_port_string((ptcr &gt;&gt; 17) &amp; 0x7));</p><p>&nbsp;<span style="white-space:pre">		</span>else</p><p>-<span style="white-space:pre">			</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>-<span style="white-space:pre">					</span>"RxFS input, ");</p><p>+<span style="white-space:pre">			</span>ret += sysfs_emit(buf + ret, "RxFS input, ");</p><p>&nbsp;</p><p>&nbsp;<span style="white-space:pre">		</span>if (ptcr &amp; IMX_AUDMUX_V2_PTCR_RCLKDIR)</p><p>-<span style="white-space:pre">			</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">			</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">					</span>"RxClk output from %s",</p><p>&nbsp;<span style="white-space:pre">					</span>audmux_port_string((ptcr &gt;&gt; 12) &amp; 0x7));</p><p>&nbsp;<span style="white-space:pre">		</span>else</p><p>-<span style="white-space:pre">			</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>-<span style="white-space:pre">					</span>"RxClk input");</p><p>+<span style="white-space:pre">			</span>ret += sysfs_emit(buf + ret, "RxClk input");</p><p>&nbsp;<span style="white-space:pre">	</span>}</p><p>&nbsp;</p><p>-<span style="white-space:pre">	</span>ret += scnprintf(buf + ret, PAGE_SIZE - ret,</p><p>+<span style="white-space:pre">	</span>ret += sysfs_emit(buf + ret,</p><p>&nbsp;<span style="white-space:pre">			</span>"\nData received from %s\n",</p><p>&nbsp;<span style="white-space:pre">			</span>audmux_port_string((pdcr &gt;&gt; 13) &amp; 0x7));</p><p>&nbsp;</p><p>--&nbsp;</p><p>2.25.1</p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p></div>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ