From patchwork Fri Jan 28 12:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 537631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 646A7C433F5 for ; Fri, 28 Jan 2022 12:07:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1B8A316E6; Fri, 28 Jan 2022 13:06:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1B8A316E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1643371618; bh=3VPYEErWl2m4i4Ta/Yjs46fsEP5ZGmBsZoI6SV932D8=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rHHAAinBkz5H0K9kulIwY1EqEnC4i8xq1/ywhMKJHpCDw1RcEIwzUMfQ8OZNQej+E TiHd5PVi2i79OUlLhvcCuKkzOIA/Q1FzD2/35m9xQbc4EFCjSaBu48MsTpXapieu9D dVo1NSkiRqF/kVtkO51XVbaG5gPBBXQXRPfIjSVA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A5C2DF8023B; Fri, 28 Jan 2022 13:06:07 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D79C3F8014B; Fri, 28 Jan 2022 13:06:05 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 05BCEF8014B for ; Fri, 28 Jan 2022 13:05:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05BCEF8014B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LJF1IZYx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643371560; x=1674907560; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3VPYEErWl2m4i4Ta/Yjs46fsEP5ZGmBsZoI6SV932D8=; b=LJF1IZYx4I/3F8ZrqkdMXxol1nYcHCfixU4xw1xAgrXkOdPqhhAkcm0y 9OG3vepWFjMB+bc8SJ3vwmXL1oUdFQJR//sDfgQpmJqTCkkXRAjz//9e3 7mWNxq5ZHXoLx5PYcD5wAD60h1tGSyc1EKYG+HIb0LtUX4jvL0baRGlZM kRGFZg7ItF5gHmqkZTZeMnPECOjvD+Kg/UKeW6MJHAhBZSu3LKCO1FIzI QuAkoI/1TEoAl3ohFdxJv+bGW48gh9HA+BQnR3zKlRvG+98K0hoBA3K4i PZyoB/zrQmWWuR2zbNFaOTNOUKhi2Xr42GlbOn+AJ0tE4IXyvgWd8Fg+x A==; X-IronPort-AV: E=McAfee;i="6200,9189,10240"; a="245949508" X-IronPort-AV: E=Sophos;i="5.88,323,1635231600"; d="scan'208";a="245949508" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 04:05:55 -0800 X-IronPort-AV: E=Sophos;i="5.88,323,1635231600"; d="scan'208";a="536109941" Received: from dlita-mobl2.ger.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.249.43.152]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 04:05:53 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH] ASoC: SOF: trace: Simplify count adjustment in trace_read Date: Fri, 28 Jan 2022 14:06:27 +0200 Message-Id: <20220128120627.18443-1-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.35.0 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com, ranjani.sridharan@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The first count check and fixup against "buffer - lpos" can be removed as we will do the adjustment later against the "avail" in sof_dfsentry_trace_read() Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan --- sound/soc/sof/trace.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c index f13024c8ebf2..9b505c4fe794 100644 --- a/sound/soc/sof/trace.c +++ b/sound/soc/sof/trace.c @@ -308,9 +308,6 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer, lpos_64 = lpos; lpos = do_div(lpos_64, buffer_size); - if (count > buffer_size - lpos) /* min() not used to avoid sparse warnings */ - count = buffer_size - lpos; - /* get available count based on current host offset */ avail = sof_wait_trace_avail(sdev, lpos, buffer_size); if (sdev->dtrace_error) { @@ -319,7 +316,8 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer, } /* make sure count is <= avail */ - count = avail > count ? count : avail; + if (count > avail) + count = avail; /* copy available trace data to debugfs */ rem = copy_to_user(buffer, ((u8 *)(dfse->buf) + lpos), count);