From patchwork Tue Oct 25 09:02:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 10609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp892090wru; Tue, 25 Oct 2022 02:08:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4q02bV0qsKsvLi4y4sNrWvAYm/yYRwed+OwViAui5G0bZp7GoGx+GnhUtSTmxbzUIgn21D X-Received: by 2002:a17:906:8a47:b0:7a5:8160:19a6 with SMTP id gx7-20020a1709068a4700b007a5816019a6mr10548664ejc.477.1666688901734; Tue, 25 Oct 2022 02:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666688901; cv=none; d=google.com; s=arc-20160816; b=M/pTz9oo0tXbuHjWBlB7+aIbPqSUUC6J8uvG/heA5tKmT3Q7QUHhSuJ1ODzW5Qg5Jt 9EhfnBwAQNAmGDFR43OdCDxK/17WWYKq9XhcffDKOOihVaLkG7/XkrH6vkIJ2qLbZmU/ 63Q/eQnTwzpLub7EsP/rZ9GaryyzaSahmAxBS6ksx1acAUZkuTtp85hDO6QwTxVvBbNz kcU+aojom/DVpCD559QyQNxDS3EGWznbZ8YsIXeQjpizjYgBKRyIo4gC9FtiMqtwwKxy 0AKdj/80PP8aDZ1AOscEUA69xUziOwmuqEGnoeFRCrt6e2PjO7W9GUJVv6kVhZF0MGiG VSvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ylbVVHeJlhDmGmH3jKJ+RzVplKRgDHmIsJb3HwB446I=; b=rgkOp+vea8mtxzG7rOQ+8KJbjMXDFs8x92BHUVwALG1X/pEipTpifcV1lM3ASizlSA H6fepFO1fLTKmuCRnheFV6L48E5jmPuwMSCYEuzLIFD7h7dY4doCyTq++TEQcWvl+NKs nlZq8urUjjqP9EdwD9MfIly+oFh3+NbaDq+2APQeJ5ExssGzIW8bTKZi2TEQ21hAZamg I+TI8ZvRfEzmM3oqozVV/JbiaKtnlt1LouX7KmczOoCNXlZBukzmB4d6THLYtsJYwrCb HFpXCjkYtccH82odziL6VGF4+MbdAiow8za8O3OJBL3WEh4EqsRgPBJLlwjSmtoo5rKw JL3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zIeW+hrb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a170906a11400b0078ddde15fdcsi1953892ejy.279.2022.10.25.02.07.56; Tue, 25 Oct 2022 02:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zIeW+hrb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231494AbiJYJGJ (ORCPT + 99 others); Tue, 25 Oct 2022 05:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231907AbiJYJEq (ORCPT ); Tue, 25 Oct 2022 05:04:46 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA02515F307; Tue, 25 Oct 2022 02:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666688636; x=1698224636; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LjeGsdYCefXiEWQEBGPfLc9etcjK2kghqSXsMXBSD/o=; b=zIeW+hrbSuEFa0p0JMmY40Pbi8BF5gx0XK8pb3SQ9P/JHbHgEJuPRQ5Y YYt3rpvlXoNVOFWNgEweaCV9LJWdrJ4e73aSzE9nq5ZPrkvfifJ/ekkgr Ty5kcwP3SgokSjoFXNMnM5FWd+Sf/mrhtreNkoYN5E1AVURxMP9AAvV3U PXQjxx1y22ccM4OxBySR/HMEmVCzWLMoU6hsmFq/O/YYF7f3cJ/MCXbke jgX+xfkO24LPWraVceT7RdMo1YG4VD/dxEzPkVN8ZPlLY/MbcAuG4PO6a DxcyoSgkcHVYu3o+Ah9ypJ4wFW21LbvR16pS9AiX59skbThHFp+Qni6ZQ A==; X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="180386445" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Oct 2022 02:03:55 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 25 Oct 2022 02:03:55 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Tue, 25 Oct 2022 02:03:52 -0700 From: Tudor Ambarus To: , , CC: , , , , , , , "Tudor Ambarus" , Subject: [PATCH v2 14/32] dmaengine: at_hdmac: Fix impossible condition Date: Tue, 25 Oct 2022 12:02:48 +0300 Message-ID: <20221025090306.297886-15-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025090306.297886-1-tudor.ambarus@microchip.com> References: <20221025090306.297886-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747649982062120270?= X-GMAIL-MSGID: =?utf-8?q?1747649982062120270?= The iterator can not be greater than ATC_MAX_DSCR_TRIALS, as the for loop will stop when i == ATC_MAX_DSCR_TRIALS. While here, use the common "i" name for the iterator. Fixes: 93dce3a6434f ("dmaengine: at_hdmac: fix residue computation") Signed-off-by: Tudor Ambarus Cc: stable@vger.kernel.org --- drivers/dma/at_hdmac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 968a5aba47cd..afcbad3e1718 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -318,7 +318,8 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) struct at_desc *desc_first = atc_first_active(atchan); struct at_desc *desc; int ret; - u32 ctrla, dscr, trials; + u32 ctrla, dscr; + unsigned int i; /* * If the cookie doesn't match to the currently running transfer then @@ -388,7 +389,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) dscr = channel_readl(atchan, DSCR); rmb(); /* ensure DSCR is read before CTRLA */ ctrla = channel_readl(atchan, CTRLA); - for (trials = 0; trials < ATC_MAX_DSCR_TRIALS; ++trials) { + for (i = 0; i < ATC_MAX_DSCR_TRIALS; ++i) { u32 new_dscr; rmb(); /* ensure DSCR is read after CTRLA */ @@ -414,7 +415,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) rmb(); /* ensure DSCR is read before CTRLA */ ctrla = channel_readl(atchan, CTRLA); } - if (unlikely(trials >= ATC_MAX_DSCR_TRIALS)) + if (unlikely(i == ATC_MAX_DSCR_TRIALS)) return -ETIMEDOUT; /* for the first descriptor we can be more accurate */