From patchwork Tue Mar 1 07:58:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Tong X-Patchwork-Id: 12764279 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CD23C433FE for ; Tue, 1 Mar 2022 07:59:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B7138D0009; Tue, 1 Mar 2022 02:59:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23FB48D0001; Tue, 1 Mar 2022 02:59:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E0628D0009; Tue, 1 Mar 2022 02:59:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 005F38D0001 for ; Tue, 1 Mar 2022 02:59:26 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C6BD51496 for ; Tue, 1 Mar 2022 07:59:26 +0000 (UTC) X-FDA: 79195067532.01.C7459AA Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 4FB8940004 for ; Tue, 1 Mar 2022 07:59:26 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 139so13795493pge.1 for ; Mon, 28 Feb 2022 23:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ekN4siAZvBFYd9yFklz7czO7Ig0JL/XxTSkd0vY2Yt8=; b=Kz+4lJxpn6ZgNlG3qZPKUsrxvOx+u6q7ExG1ZalqIm2eoUgzkmKQ18EPS8Y2gJ91ws ok2nLgOjheo5Q+JkSgWrbzHDQpQa5YOuFW3unn1k1/7oZ0HgwPOrZIe2pesso6MHMbRP bZzU3Cz9/18EGeHCFtChKtNwLPgdwcTb5joSEyWFCDalPn4pWeVOSJaVpa2UJWelNXo7 nW275yP5KtdIIFFzENZdI2cq35OKDfDJ47rPXJa5QgRa8MoylJN0zGyv7syuj6ACJMJU wP71gwseBBGoxOdHN/stX4Rz3Pzt08bTEZ5h4DDmVo+SpG06gBNUEOGFabRPha8U2EyC LGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ekN4siAZvBFYd9yFklz7czO7Ig0JL/XxTSkd0vY2Yt8=; b=QYW5/PSQd67xn3foTxls3v/WC8bnY97UyBWTpjfv+D1bM9+1sVbNICpgkLGcLDAteB 9VJksBx/mscZoNd0o8UJC5BLY0fMaxSd34SoSF5ZgCF+yWkJ1f8gPwolxVD2azi3P6WX 8uYs6rnxpQtRaJsNczUsV48/LSjqweUPojwk9+dfFj/EptBj2ekXv8FyRvcP1miinv5S 2HaLWph1TFmM3tmFPviy2Qj0sIKWOHByrrbyFlEvT+lWJZl88TXyiSZ7mhJszxyu00dp v8msaiNt5vDU1r7NGiyBMiOvmp2mitTORW1p7J8haBXbKWqwtp0iqpYw0dwcledHSoLT R1wQ== X-Gm-Message-State: AOAM5322ty8nMvxjeK/d5Z3dBamRGoi36f0xWXtDnu+yxmNca1sRv2Nr 9jjMlu/Ei7J5pamWc6VU+DA= X-Google-Smtp-Source: ABdhPJwXvPb7Q40+8gxqteNpuZwp+PE+h/n6nJyCxWSbGjj0S4pZaxg41DZenCjeRXk3a7weBaal7A== X-Received: by 2002:a65:680a:0:b0:34d:efd6:7a5f with SMTP id l10-20020a65680a000000b0034defd67a5fmr20435429pgt.213.1646121565470; Mon, 28 Feb 2022 23:59:25 -0800 (PST) Received: from ubuntu.huawei.com ([119.3.119.18]) by smtp.googlemail.com with ESMTPSA id o12-20020a17090aac0c00b001b9e5286c90sm1662745pjq.0.2022.02.28.23.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 23:59:25 -0800 (PST) From: Xiaomeng Tong To: torvalds@linux-foundation.org Cc: arnd@arndb.de, jakobkoschel@gmail.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, jannh@google.com, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, Xiaomeng Tong Subject: [PATCH 6/6] drivers/dma: remove iterator use outside the loop Date: Tue, 1 Mar 2022 15:58:39 +0800 Message-Id: <20220301075839.4156-7-xiam0nd.tong@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220301075839.4156-1-xiam0nd.tong@gmail.com> References: <20220301075839.4156-1-xiam0nd.tong@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4FB8940004 X-Stat-Signature: wg1ci7epfqubcjbcntnd8sqtfoykbdiw Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Kz+4lJxp; spf=pass (imf01.hostedemail.com: domain of xiam0nd.tong@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=xiam0nd.tong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1646121566-393823 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Demonstrations for: - list_for_each_entry_from_inside - list_for_each_entry_safe_from_inside Signed-off-by: Xiaomeng Tong --- drivers/dma/iop-adma.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 310b899d5..2f326fb37 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c @@ -159,7 +159,6 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) /* all the members of a group are complete */ if (slots_per_op != 0 && slot_cnt == 0) { - struct iop_adma_desc_slot *grp_iter, *_grp_iter; int end_of_chain = 0; pr_debug("\tgroup end\n"); @@ -167,9 +166,8 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) if (grp_start->xor_check_result) { u32 zero_sum_result = 0; slot_cnt = grp_start->slot_cnt; - grp_iter = grp_start; - list_for_each_entry_from(grp_iter, + list_for_each_entry_from_inside(grp_iter, grp_start, &iop_chan->chain, chain_node) { zero_sum_result |= iop_desc_get_zero_result(grp_iter); @@ -186,9 +184,8 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan) /* clean up the group */ slot_cnt = grp_start->slot_cnt; - grp_iter = grp_start; - list_for_each_entry_safe_from(grp_iter, _grp_iter, - &iop_chan->chain, chain_node) { + list_for_each_entry_safe_from_inside(grp_iter, _grp_iter, + grp_start, &iop_chan->chain, chain_node) { cookie = iop_adma_run_tx_complete_actions( grp_iter, iop_chan, cookie);