From patchwork Mon Jul 2 21:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 10502549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C21F6028F for ; Mon, 2 Jul 2018 22:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A06928AB7 for ; Mon, 2 Jul 2018 22:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0CCF28AD3; Mon, 2 Jul 2018 22:26:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AFB028AB7 for ; Mon, 2 Jul 2018 22:26:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0549C26771C; Tue, 3 Jul 2018 00:26:11 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 37D67267731; Tue, 3 Jul 2018 00:26:09 +0200 (CEST) Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by alsa0.perex.cz (Postfix) with ESMTP id 7681B26771C for ; Tue, 3 Jul 2018 00:26:07 +0200 (CEST) Received: by mail-io0-f196.google.com with SMTP id q9-v6so5338019ioj.8 for ; Mon, 02 Jul 2018 15:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dX9pP/dh5n477QsEVY5f6zeNdJXdS406ea9F9OtRySo=; b=ocLWewXH1FUa0J+jePdoJA8yu0+MG3C6DIwhwj8byaUcjsOiLvHUJOiU/CjJXJc/1r +AI4cNtmpBYCmPKNVE/OqugGfZLpmT97H1bV7QbW5vxNON5NGdT2fmXHAugO4wlp+Wyu gscxm/YOfiAwt9exfePToXjWtxdnnR82QnUF4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dX9pP/dh5n477QsEVY5f6zeNdJXdS406ea9F9OtRySo=; b=THDKwoee3MhU8r6r28Y5atKofyycxqQx2smiq6QjXGVMJjNBWKIqxuWP5NjRl+yOdQ 6lHC3MF0kWbSqhTDjl+RfSWU5Co6ZvTHRGUJSkUkTvfYCXg88whfuawu8eNyRC8rEOb2 18LlJtPJGiRKU1/a5qvjFeu/DEo8rTXOwCcCOcPDsJFKX0gz3vkkEkmFDBNIsmYnksR4 Jg76vS/loGOvjyScwrjOc4JnWuoMdb/S6SJtd3BdcodmWXFetH0ZjV9uDku4YqCs023D x5ucB+Ow7yIVq2QZtFoSCGtm4TEsKQz713Ubg4iVTU9DNMTpTjpvBbiriZIBBmiPYGva Xn+Q== X-Gm-Message-State: APt69E0z3638oKD+gYBEExRjzuS/tst3pULlq3k4cAQg+uc5H3a0ttpQ nOM0+8s79EugIcJ0hTzOuE4mXo9BN+U= X-Google-Smtp-Source: AAOMgpdwqnNtLpHUfUHBQGNc55kHh6kr0NaR0VxQHNzfX+LfyR5eXgDDaYGVXW8znqhdIj/m6i3s4g== X-Received: by 2002:a6b:28c6:: with SMTP id o189-v6mr22006296ioo.149.1530566407366; Mon, 02 Jul 2018 14:20:07 -0700 (PDT) Received: from djkurtz2.bld.corp.google.com ([2620:15c:183:0:1cfd:61a5:7215:5f9c]) by smtp.gmail.com with ESMTPSA id h75-v6sm776729ioh.50.2018.07.02.14.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 14:20:06 -0700 (PDT) From: Daniel Kurtz To: Date: Mon, 2 Jul 2018 15:19:52 -0600 Message-Id: <20180702211956.149355-3-djkurtz@chromium.org> X-Mailer: git-send-email 2.18.0.399.gad0ab374a1-goog In-Reply-To: <20180702211956.149355-1-djkurtz@chromium.org> References: <20180702211956.149355-1-djkurtz@chromium.org> Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Takashi Iwai , Daniel Kurtz , Liam Girdwood , Mark Brown , "Mukunda, Vijendar" , Alex Deucher , Guenter Roeck , Akshu Agrawal Subject: [alsa-devel] [PATCH 3/6] ASoC: AMD: Always subtract bytescount X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP It is always correct to subtract out the starting bytescount value. Even in the case of 2^64 byte rollover (292 Million Years in the future @ 48000 Hz) the math still works out. Signed-off-by: Daniel Kurtz --- sound/soc/amd/acp-pcm-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index e6f85f2e5ac2a..224383fef0c3a 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -995,8 +995,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) buffersize = frames_to_bytes(runtime, runtime->buffer_size); bytescount = acp_get_byte_count(rtd); - if (bytescount > rtd->bytescount) - bytescount -= rtd->bytescount; + bytescount -= rtd->bytescount; pos = do_div(bytescount, buffersize); return bytes_to_frames(runtime, pos); }