Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2191327pxb; Fri, 25 Mar 2022 12:44:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNKL7RxkYUqI/ofcnewflmtsWr8OPVX0bjRbvOkvbLvC4i2JB5wZHuTtK504mnpjEwbkXb X-Received: by 2002:a05:6a00:338e:b0:4fa:9015:af50 with SMTP id cm14-20020a056a00338e00b004fa9015af50mr11736796pfb.57.1648237443991; Fri, 25 Mar 2022 12:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648237443; cv=none; d=google.com; s=arc-20160816; b=uN8ZJUDtHdXSsXPR2LAraX6Zu78LVv2ZZbM+cqUIXDWi4I0oKCrc+KrT1iWFBju9Jt 1uC/xtSWvOh5xn6pWBWkQJsJhIm3oAB/jwUM//Vor/GZtdcCVthDDS60Q8WogZOq+Ui+ 6us9OYryEY1dFOvBcx6DYaDBwA/AGmn+BQ9qJ6Ws71Tyy1UoOX/lyrlXXrGLbv+/Vh3f 2bLPKDVzmafpRLlAkz0nMnWWWlM+dI1iaM+BgXvhJFYnAOSAXgzynrxjkNLq8xSAelao sDfz8ckkBAEDz61NMLdhkqur1rTmCAuY6hluU29g4YeUllet4s/sxJf6wgIjySXyH1+q BEvA== 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=x0TKyRRyasBlRl7/S8dZGTjcoSJS62R91ivStapMPWY=; b=CEm6y0pi9kQQaE9TzAbAplLCkJJqaA7u6xuUWCvFyB+KnUT/0EeyNMOlfxjFOjUsoB V2HMyBtTKQPOz/8ie4LIjDIwLC2aWgsHhXJMR9PFvqxe10JtjAAcvXPi9FFRjJl9UfxV O4RsxmUSxeBwDoG9ff5UaUc35CH5YIRi8a9sdNoJe98xrU4VRS5Bo4GRimFl3Y+cAhZj LriV1fE4KcA5EkkDl6tbA1H7DWBv2ZLbfOTq/ZtGKORQb9lFwkTkqlmwpSvkl3uZHmyv 1TD1c2FhRU4RWWLnIfeiOg71UWvq6JfesQgQ4tEaitGVJeu9f0njDTzdbhTHfpj24Ozs 2KMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EllCSYlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x18-20020a170902b41200b00153b2d1640bsi3412208plr.19.2022.03.25.12.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:44:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EllCSYlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 1FD33B0A43; Fri, 25 Mar 2022 11:34:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348398AbiCXHMp (ORCPT + 99 others); Thu, 24 Mar 2022 03:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238062AbiCXHMn (ORCPT ); Thu, 24 Mar 2022 03:12:43 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D950985A5 for ; Thu, 24 Mar 2022 00:11:12 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id dr20so7270607ejc.6 for ; Thu, 24 Mar 2022 00:11:12 -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=x0TKyRRyasBlRl7/S8dZGTjcoSJS62R91ivStapMPWY=; b=EllCSYlG1r+Ax169Is9zyo8MY3QlyQf8CLMF1RgC0Ht/rQN/5ThZ/m/yoHj1xst9zz eXdKEC8LXFTR4mV5whqje7ZHLNpiNMsYWEsi5esT6jlnF7vCLbohVbUCtQHMO58ND/l8 E8d8izGVHM4ipCcuIu6DfaxVmFL2Vl9mvzzXL9WB6P39BktDTEt3IWV/uaQNNbY/LUbv 5oGSWToEAckJhYlAmZl42SzDFyIfjsf4IlD5hUdQdXZXV+SACp74CbtqV+fXKFyzjgO5 7WBhiebIGcw2xLm1YonXPx3cJC3oZv+kQdqK8JoFamtGfoU/bc8QCKB2fp8IJv52rQLa Z0EQ== 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=x0TKyRRyasBlRl7/S8dZGTjcoSJS62R91ivStapMPWY=; b=15kjz9Y7iSzs215M4BD/SFIE1X/YlH6aKuVxzIczJS2kuw849AURa4qc5cw/EGsweM bmR3ljjJJ0nUjYAamBPUrmnLaooyktLmnNo14JqMY+iCtNqKwy8tKVIgKfWn9nTZLuBL Iy5mok3nl+Onl89KLxXOfEW/kM7uSs7+IcqXG6iv2ptBRHxkAqWio9FEdPN0u53swBsr OYPewg59+2N4u6sxtrOI65g3d0CPG/O4kzvIlTg9e+0fp3bil1TH2BVIue4virGULlEx FXJ+Fyy04eAGHgEJBcAmsMJ7Lw00eescF1Pov+POuop0vEB5h/tShaIypVhS/z8dOkdm A4GA== X-Gm-Message-State: AOAM533dZRf3txr8Xj9QdGavI1nsZBXhHDe+TdCLOO+I0EIpctUHHazq ZC0K5e6T6IME64iytWbUQXc= X-Received: by 2002:a17:907:c018:b0:6df:fb9b:e6f8 with SMTP id ss24-20020a170907c01800b006dffb9be6f8mr4026860ejc.495.1648105870759; Thu, 24 Mar 2022 00:11:10 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id di6-20020a170906730600b006df8831ec5asm769937ejc.114.2022.03.24.00.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:11:10 -0700 (PDT) From: Jakob Koschel To: Oded Gabbay Cc: Arnd Bergmann , Greg Kroah-Hartman , Ofir Bitton , Dani Liberman , Ohad Sharabi , farah kassabri , linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] habanalabs: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:10:48 +0100 Message-Id: <20220324071048.59659-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/misc/habanalabs/common/command_submission.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/misc/habanalabs/common/command_submission.c b/drivers/misc/habanalabs/common/command_submission.c index 0a4ef13d9ac4..4927749e439c 100644 --- a/drivers/misc/habanalabs/common/command_submission.c +++ b/drivers/misc/habanalabs/common/command_submission.c @@ -405,8 +405,7 @@ static void staged_cs_put(struct hl_device *hdev, struct hl_cs *cs) static void cs_handle_tdr(struct hl_device *hdev, struct hl_cs *cs) { - bool next_entry_found = false; - struct hl_cs *next, *first_cs; + struct hl_cs *next = NULL, *iter, *first_cs; if (!cs_needs_timeout(cs)) return; @@ -441,13 +440,13 @@ static void cs_handle_tdr(struct hl_device *hdev, struct hl_cs *cs) spin_lock(&hdev->cs_mirror_lock); /* queue TDR for next CS */ - list_for_each_entry(next, &hdev->cs_mirror_list, mirror_node) - if (cs_needs_timeout(next)) { - next_entry_found = true; + list_for_each_entry(iter, &hdev->cs_mirror_list, mirror_node) + if (cs_needs_timeout(iter)) { + next = iter; break; } - if (next_entry_found && !next->tdr_active) { + if (next && !next->tdr_active) { next->tdr_active = true; schedule_delayed_work(&next->work_tdr, next->timeout_jiffies); } base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1