Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2056202pxb; Fri, 25 Mar 2022 10:18:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxNF03ouQ7OyCbPqt9aqeA68SyCD0AEU6BWb0H4AkAXr1H3dKvGPTCqPsedqm9s8l4QhSu X-Received: by 2002:ad4:596a:0:b0:441:4ef:e1c4 with SMTP id eq10-20020ad4596a000000b0044104efe1c4mr9971582qvb.90.1648228711460; Fri, 25 Mar 2022 10:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648228711; cv=none; d=google.com; s=arc-20160816; b=hT95Hesb94/8vvF8f+tGLMGaHo5qrVy43Ls2FtXPoQ+OXxk7m+JMWi7gn95/+Zo/tC BUwxzcD8aLvcosb5VQKr3otW5LYZRD9unuWX61aHINcKTpdr59oDAD2CgFoEZfTymzDm /m9oNJmX//ZCkn0fQv3XW5JJqRLL5T1OOToM4dq7s/L+7iYarg8ndCQ6eS9qKK/vpQj7 tzykQvHOaH0Ry1vI6qgDTzwYK668V4rPEQVpXx8q03LVSZGbDyVINbQ6xPGPJQP9YG3v /rDP5aVbNNLJpeOSCR/2qqo/0z41mCrTG4xdf0+5V5hbzH3e0kV4BfEt1IISlnZUbHKe uC/g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ouqixWTewNUXByCDOAWSWsgjahXSnZ2j4PO6S0OVSBc=; b=0Xevk3PUuA3H+ZYg24OtiYjiRwVySelMPSdEvmC1PBq6WSM8Xy3kbNHPvMF9KOFsKH DZGlpSX8B15X3IQk3cD7nBMiZ0e/s4Jt0+JyyuuyCYlEZ7I3tKRJWJ9XR/TOwmcezlP7 q8yiwXcHpzKsDIN5Vp3t4X4Eg4tUrOn+m0AAXFbSBvuxWuBksqx/G/HijqRLLDw5D/jv 4FoTJT3gnAJHjFxJK7DKR7Roc5nLMCtPnl3N+YpvUoql7JkOE42Z9u203ArLyR0V7bHG iBSQeewFcRLE0vSvHGywCj/TBKNOE0V3ftSQcLoD6vkTVt6X26jNNs6Tbfuq4MPDZvl/ jIsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cFugzm9z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j11-20020a05620a410b00b0067e4be23834si1961247qko.121.2022.03.25.10.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:18:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cFugzm9z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 277C7ECC45; Fri, 25 Mar 2022 10:17:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348510AbiCXH1A (ORCPT + 99 others); Thu, 24 Mar 2022 03:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234921AbiCXH06 (ORCPT ); Thu, 24 Mar 2022 03:26:58 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3382986F4 for ; Thu, 24 Mar 2022 00:25:26 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id qa43so7283438ejc.12 for ; Thu, 24 Mar 2022 00:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ouqixWTewNUXByCDOAWSWsgjahXSnZ2j4PO6S0OVSBc=; b=cFugzm9zbfF2ycvf5BO0ObBa7AQEVHzluHn+MgplO8ys+X0ReVhk3ZOkfYRfFH4yH6 YKk3XkBP3jZQIDY3wu5m9xl/XGIwMgjbeSsZznDQ6FDQMdc8mDvHDKrUx6RRvDYu0UYX Xjn7GgPG/xKghClCJY6FIUAoq6WusLrrVglke8puMsBnaudwanX8vFEkvBChz2Wjj4+X 7Zjj795X79I8/brB6mIYiRu84KYvW0+2I1R8cSMFUiETvoPkRAt1RTMxxuUObnP0rAIk QnoChzCHgwQzx9b4eMHbkDxvQ4/00+NTAsuCzdI4N75XyCfbJdAh7cTQgns+0lOgS2JX GTIQ== 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:mime-version :content-transfer-encoding; bh=ouqixWTewNUXByCDOAWSWsgjahXSnZ2j4PO6S0OVSBc=; b=pd4WwQyJg5bpFNIS02fzytHfKdeULueiSsUOXFD8nR1i345kc6EnJb3RGMPLfRZZ8D G3oiq6MwROPVhNynOHFnsBYBLXj0Kzhgr+ZT7dSSSvNLXKPx56IlmbtMLUZBkPXbbiY+ 1gKCjcXNUoEqhf3PL1LQRKa9xwqb6mhlW7eyY+xbc8Tfpjzx7mXaOYbPOpPCrGOG/1Db IB1PiBnj7xiDSwYoyxY5MMkytIyI1pQOC9qfNsC7EavZ4Od8XuZz60FCZRr4VX6u22C2 8NLEApO9Bkvyt4d3+MvFHmhoKvnX2rbosMCqLkXqTvDHMdttqYOY8k2MAmrzuDp1fWuz SSbg== X-Gm-Message-State: AOAM533TLMTyccAxXCqf8lfkBcqWGrVgqLOSmdo192xQ7sO+ARUS0M5d P2NWvvTFMMK3BCPtYzij8vA= X-Received: by 2002:a17:907:1dc8:b0:6df:f5fc:f4f9 with SMTP id og8-20020a1709071dc800b006dff5fcf4f9mr4169480ejc.739.1648106725293; Thu, 24 Mar 2022 00:25:25 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id l9-20020a1709060cc900b006ce04bb8668sm765382ejh.184.2022.03.24.00.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:25:24 -0700 (PDT) From: Jakob Koschel To: Nishanth Menon Cc: Santosh Shilimkar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] soc: ti: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:25:03 +0100 Message-Id: <20220324072503.63244-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel --- drivers/soc/ti/knav_dma.c | 26 ++++++++++++-------------- drivers/soc/ti/knav_qmss_queue.c | 16 +++++++--------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c index 700d8eecd8c4..7e126a73e56e 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c @@ -415,9 +415,8 @@ static int of_channel_match_helper(struct device_node *np, const char *name, void *knav_dma_open_channel(struct device *dev, const char *name, struct knav_dma_cfg *config) { - struct knav_dma_chan *chan; - struct knav_dma_device *dma; - bool found = false; + struct knav_dma_device *dma = NULL, *iter1; + struct knav_dma_chan *chan = NULL, *iter2; int chan_num = -1; const char *instance; @@ -444,33 +443,32 @@ void *knav_dma_open_channel(struct device *dev, const char *name, } /* Look for correct dma instance */ - list_for_each_entry(dma, &kdev->list, list) { - if (!strcmp(dma->name, instance)) { - found = true; + list_for_each_entry(iter1, &kdev->list, list) { + if (!strcmp(iter1->name, instance)) { + dma = iter1; break; } } - if (!found) { + if (!dma) { dev_err(kdev->dev, "No DMA instance with name %s\n", instance); return (void *)-EINVAL; } /* Look for correct dma channel from dma instance */ - found = false; - list_for_each_entry(chan, &dma->chan_list, list) { + list_for_each_entry(iter2, &dma->chan_list, list) { if (config->direction == DMA_MEM_TO_DEV) { - if (chan->channel == chan_num) { - found = true; + if (iter2->channel == chan_num) { + chan = iter2; break; } } else { - if (chan->flow == chan_num) { - found = true; + if (iter2->flow == chan_num) { + chan = iter2; break; } } } - if (!found) { + if (!chan) { dev_err(kdev->dev, "channel %d is not in DMA %s\n", chan_num, instance); return (void *)-EINVAL; diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 2ac3856b8d42..4dbaa8c3636c 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -758,10 +758,9 @@ void *knav_pool_create(const char *name, int num_desc, int region_id) { struct knav_region *reg_itr, *region = NULL; - struct knav_pool *pool, *pi; + struct knav_pool *pool, *pi = NULL, *iter; struct list_head *node; unsigned last_offset; - bool slot_found; int ret; if (!kdev) @@ -816,18 +815,17 @@ void *knav_pool_create(const char *name, * the request */ last_offset = 0; - slot_found = false; node = ®ion->pools; - list_for_each_entry(pi, ®ion->pools, region_inst) { - if ((pi->region_offset - last_offset) >= num_desc) { - slot_found = true; + list_for_each_entry(iter, ®ion->pools, region_inst) { + if ((iter->region_offset - last_offset) >= num_desc) { + pi = iter; break; } - last_offset = pi->region_offset + pi->num_desc; + last_offset = iter->region_offset + iter->num_desc; } - node = &pi->region_inst; - if (slot_found) { + if (pi) { + node = &pi->region_inst; pool->region = region; pool->num_desc = num_desc; pool->region_offset = last_offset; base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1