From patchwork Sat Mar 15 06:15:11 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: 14017719 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) (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 D63E619539F; Sat, 15 Mar 2025 06:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.216.63.40 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019323; cv=none; b=K8zuxHqsWiv68yJDErJFl0pmWJ8RVHotSWzoHJEAOgBnjLYW1iV0fpEvybRhDrHYVAUBEcfxzgqo129FU+lCD0aIkKhXrfeEmOtMqc89cNsMuE1CSZVjiBqi3fhBnRypEXqS7ZiF9/6CupjN81JZP8P6d5IPZNPse3mUO7al7w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742019323; c=relaxed/simple; bh=JCKlWqJuZdkHoNK0McQGH+nearGD+CoJy6QPiDs0y1A=; h=Date:Message-ID:Mime-Version:From:To:Cc:Subject:Content-Type; b=JG0NuA3v4TmLQ96a0UUPex10ImFItimlQNCNfNbn6VMm5dPW9QcnDo4EHYprV70G2D/5/6cUOhhxbnxsDP82YlkYgbpxXi6elm0TZCQfy5VdU6VNzzKX/72jSvbOIbd50JEqS+wXizO33z3aqbhMlt8cBPxePfIUZ42vYlj6IVw= 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.40 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 4ZF9vS3DvWz8R040; Sat, 15 Mar 2025 14:15:16 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl2.zte.com.cn with SMTP id 52F6F9nD054688; Sat, 15 Mar 2025 14:15:09 +0800 (+08) (envelope-from xie.ludan@zte.com.cn) Received: from mapi (xaxapp05[null]) by mapi (Zmail) with MAPI id mid32; Sat, 15 Mar 2025 14:15:11 +0800 (CST) Date: Sat, 15 Mar 2025 14:15:11 +0800 (CST) X-Zmail-TransId: 2afc67d51aef53c-65333 X-Mailer: Zmail v1.0 Message-ID: <202503151415111195hBKdQ6LAKcngyEswq9k5@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-fl2.zte.com.cn 52F6F9nD054688 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 67D51AF4.000/4ZF9vS3DvWz8R040 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));