Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:14 xie.ludan
  0 siblings, 0 replies; 5+ messages in thread
From: xie.ludan @ 2025-03-15  6:14 UTC (permalink / raw)
  To: xiubo.lee
  Cc: shengjiu.wang, festevam, nicoleotsuka, lgirdwood, broonie, perex,
	tiwai, shawnguo, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
	linux-arm-kernel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 2519 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>
---
 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

[-- Attachment #1.1.2: Type: text/html , Size: 5429 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:15 xie.ludan
  0 siblings, 0 replies; 5+ messages in thread
From: xie.ludan @ 2025-03-15  6:15 UTC (permalink / raw)
  To: xiubo.lee
  Cc: shengjiu.wang, festevam, nicoleotsuka, lgirdwood, broonie, perex,
	tiwai, shawnguo, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
	linux-arm-kernel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 2519 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>
---
 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

[-- Attachment #1.1.2: Type: text/html , Size: 5429 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:15 xie.ludan
  0 siblings, 0 replies; 5+ messages in thread
From: xie.ludan @ 2025-03-15  6:15 UTC (permalink / raw)
  To: xiubo.lee
  Cc: shengjiu.wang, festevam, nicoleotsuka, lgirdwood, broonie, perex,
	tiwai, shawnguo, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
	linux-arm-kernel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 2519 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>
---
 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

[-- Attachment #1.1.2: Type: text/html , Size: 5429 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:15 xie.ludan
  2025-03-17  6:21 ` Jiri Slaby
  0 siblings, 1 reply; 5+ messages in thread
From: xie.ludan @ 2025-03-15  6:15 UTC (permalink / raw)
  To: xiubo.lee
  Cc: shengjiu.wang, festevam, nicoleotsuka, lgirdwood, broonie, perex,
	tiwai, shawnguo, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
	linux-arm-kernel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 2519 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>
---
 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

[-- Attachment #1.1.2: Type: text/html , Size: 5429 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf().
  2025-03-15  6:15 [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf() xie.ludan
@ 2025-03-17  6:21 ` Jiri Slaby
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2025-03-17  6:21 UTC (permalink / raw)
  To: xie.ludan, xiubo.lee
  Cc: shengjiu.wang, festevam, nicoleotsuka, lgirdwood, broonie, perex,
	tiwai, shawnguo, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
	linux-arm-kernel, linux-kernel

On 15. 03. 25, 7:15, xie.ludan@zte.com.cn wrote:
> 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>
> 
> ---
> 
>   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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-17  6:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15  6:15 [PATCH linux-next] ASoC: use sysfs_emit() instead of scnprintf() xie.ludan
2025-03-17  6:21 ` Jiri Slaby
  -- strict thread matches above, loose matches on Subject: below --
2025-03-15  6:15 xie.ludan
2025-03-15  6:15 xie.ludan
2025-03-15  6:14 xie.ludan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox