From patchwork Sat Mar 15 06:15:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xie.ludan@zte.com.cn X-Patchwork-Id: 14017725 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 138D21922E0 for ; Sat, 15 Mar 2025 06:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.216.63.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019342; cv=none; b=lEO8TFMsVLm8XZSWUuUfM9MQT6fmN+Icy2C+XKmwXH+NOjl1M2u7ARvXjabDGNJaPIzKK2lCl1V+IwPyEM3xFN56RHHpDJTVFl3vz2P7XTdUxZQWtcyNWAKude2auORoz9U+DJgumDwKM4JREGHp552olWku4PuVELt5xQFaIqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019342; c=relaxed/simple; bh=JCKlWqJuZdkHoNK0McQGH+nearGD+CoJy6QPiDs0y1A=; h=Date:Message-ID:Mime-Version:From:To:Cc:Subject:Content-Type; b=uqvKgfG4O3ccdq8MhkrpiaOK+SSW0YUnoC9f8+P4M95ZJTD+sBqEMvb9cNGlw3JmT1Fyzjhm4FYliZPeeVEPYvGul8/MoWjWGZ7JfZpDlWxo04jzmsvJNlEMSC7q3GlC+dHwqi0lQEA+Gpxpmmh7p77leN7Htm+zQAqWe5+CWaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn; spf=pass smtp.mailfrom=zte.com.cn; arc=none smtp.client-ip=63.216.63.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4ZF9vv41wBz5B1J6; Sat, 15 Mar 2025 14:15:39 +0800 (CST) Received: from xaxapp04.zte.com.cn ([10.99.98.157]) by mse-fl2.zte.com.cn with SMTP id 52F6FRWR054761; Sat, 15 Mar 2025 14:15:27 +0800 (+08) (envelope-from xie.ludan@zte.com.cn) Received: from mapi (xaxapp04[null]) by mapi (Zmail) with MAPI id mid32; Sat, 15 Mar 2025 14:15:29 +0800 (CST) Date: Sat, 15 Mar 2025 14:15:29 +0800 (CST) X-Zmail-TransId: 2afb67d51b01ffffffffebe-5fcbb X-Mailer: Zmail v1.0 Message-ID: <20250315141529150fbawTX2YISM8pAvBtAksn@zte.com.cn> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_ASoC=3A_use_sysfs=5Femit=28=29_ins?= =?utf-8?q?tead_of_scnprintf=28=29=2E?= X-MAIL: mse-fl2.zte.com.cn 52F6FRWR054761 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 67D51B0B.000/4ZF9vv41wBz5B1J6 From: XieLudan 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 --- 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));