From patchwork Sat Mar 15 06:14:52 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: 14017718 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 77A048494; Sat, 15 Mar 2025 06:15:06 +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=1742019309; cv=none; b=MVcBWsJitrtRlBMs4ez2gcggH7yyXEtNi51LgOy4qN9Ctsoe7f+UjrNy/QkgjjiXOilROUJPrXlsn9T1QK5J3SglPuN0b5XDluW61Q4To1JxUlzouwBR2Pfd/sK3I2g5q4TAlYnNXDSQBM55oDxFEvMm15Pq2wSoMrzSZwkFfDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019309; c=relaxed/simple; bh=JCKlWqJuZdkHoNK0McQGH+nearGD+CoJy6QPiDs0y1A=; h=Date:Message-ID:Mime-Version:From:To:Cc:Subject:Content-Type; b=QJxOwqHpx6mvo70qQXcN1DycmrHqBqbCsDVcyTBL2ccDHsn2wii31RM07A8hv+niyJHRCzyjwDWFI1W5Pq+18j6kV2XeA1RtoChZhcugqfZJcHqrKUmyNre1APUnnJXYGEDhRbZx5GH7B92O4hHIfkgnxIGOCFIDM/NmytqLi04= 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-fl1.zte.com.cn (unknown [10.5.228.132]) (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 4ZF9vD4629z5B1J5; Sat, 15 Mar 2025 14:15:04 +0800 (CST) Received: from xaxapp04.zte.com.cn ([10.99.98.157]) by mse-fl1.zte.com.cn with SMTP id 52F6Eqfl010351; Sat, 15 Mar 2025 14:14:52 +0800 (+08) (envelope-from xie.ludan@zte.com.cn) Received: from mapi (xaxapp02[null]) by mapi (Zmail) with MAPI id mid32; Sat, 15 Mar 2025 14:14:52 +0800 (CST) Date: Sat, 15 Mar 2025 14:14:52 +0800 (CST) X-Zmail-TransId: 2afa67d51adc771-6c561 X-Mailer: Zmail v1.0 Message-ID: <20250315141452917TgYukep-fMdORK2wh1T1w@zte.com.cn> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org 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-fl1.zte.com.cn 52F6Eqfl010351 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 67D51AE8.002/4ZF9vD4629z5B1J5 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));