Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1398968pxb; Thu, 24 Mar 2022 19:48:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc7D7WlYSJf4Ooi0TCA9bWMbfyzYfGH9PQ4NFqUGUMwUMOVCAvWfWtHUtLxqIsPk3+aJhO X-Received: by 2002:a17:907:a420:b0:6e0:5b41:4875 with SMTP id sg32-20020a170907a42000b006e05b414875mr9135989ejc.494.1648176493804; Thu, 24 Mar 2022 19:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648176493; cv=none; d=google.com; s=arc-20160816; b=NZ5j/ldk+C1/smbu5VhXvjws6yvs4XDpKisfopcEWn5xT4EMWftTiEgD+Y1z0umyP9 PtYZHFH376DAxMIlANIG4dZUspYQaYLHA10Ev5luBdp363S5izkEUSY0JAq0CNWfzdCI PvBgmEN/d5JPEaHPrH1mEgyRqgBP/DulZ82oxoecXINUkHBdw0X+EQc7UeQpPXZ3ccn0 Fqyo8mllG8fhtBS0sMSQU10kaK2449rJOaitNTL8ei+fwLqS2hQFYZkAv53emvhCO5Dt uYWG+0e5qiRy76zA1sZMtUPQYa+4ts1vMJZqKgdPpxdw2DzWnJHqNjF7HMtfdlr/ThRn qS8w== 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=XVilrVPHAzNXojXt+GjJOL6H62xOPCwBdLhdn2DWXIM=; b=s0Dvy9MgnTO9IkW7lrit/Id+5vcOTfDn9gbK8PLIeZvy8G2FPt4o1ok7AQtAQ+zn6H pntHCRMg4bubN+cCH628wbi523g6iWjAGUjiS0/QxGgIs2Eb9mYzF9LpMWJkNaNWVApM wBno/ZN/VjN0HqEiM3e8vUIkV5yVzWhTYWnPNUAAAm27RIhBn1fPOWgcD0Ryy4pIGZZI U3im0ajiYMQg2mR3aFeWV6YDZ4zGx3JFk0MKBXsgCb0iqBIpUEu37+BpPCTI3badFw5x 0eOhPhj9zI8c4xtalZPmMfWVczKYeKcCsnz0it4w+gLsjw09R9ZdC6rc7LDlokYDhe5P 4HgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=otovnpD5; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020aa7c644000000b00418c2b5be92si1315396edr.372.2022.03.24.19.47.46; Thu, 24 Mar 2022 19:48:13 -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=@gmail.com header.s=20210112 header.b=otovnpD5; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348518AbiCXH12 (ORCPT + 99 others); Thu, 24 Mar 2022 03:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234921AbiCXH11 (ORCPT ); Thu, 24 Mar 2022 03:27:27 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39EFA986F4; Thu, 24 Mar 2022 00:25:56 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id r13so7327601ejd.5; Thu, 24 Mar 2022 00:25:56 -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=XVilrVPHAzNXojXt+GjJOL6H62xOPCwBdLhdn2DWXIM=; b=otovnpD5nrCVnZOsLSqe8I1OIJRwaeI6Wprpx5/aY+tLRP2xckrtLUD/siXLU0Txf3 21HyGWc+9cV2Rn0XxJyTxE6UL5SEDgTZw98y9gKL3wnDu0AEcS/eFNTmcJm4p2Y8Bfg9 QTEjKShf9Y8EAQ/C9rEPAfjempmv8JNNth7q8lGJ6Vr2y90i4WZVXozSuNiDgHBgcd7U ZjfRmpiI6Ou7+clTpm9JLqeDfSaHFj4Eev5TNir7uoSlHyP0sxtAG35Kuy+WV0TsirBo 0XCSnJKarnaRYK/EGYD4aYAaWI1Hx+7q/SleHBCKJHXoL+NxnOez9BUQc2A4WYp4otFp UM+A== 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=XVilrVPHAzNXojXt+GjJOL6H62xOPCwBdLhdn2DWXIM=; b=jfzqnxW9w4TZhkya9vuopczhWxzMhx4XRtO7Cb7Gi/ZsDR5QWcRZbO+3XtPczBrqal KJbw1kHdCQrtRgFD7qv8HdThMsYJkDMI1v45B+OmdvyKLButgG2CTw8FHBubRX3RQ1o4 WE2Dg0VAXT4HO37G1ASAvJVBBkN6Af7d2P91ttPTjK+Otu+NrPVmVOw1xWGU8rwbCPre Ng6zWd5TyD5yhJrA8EdBDPs/AEeo0gyJ4hzrYqxiPrQYIkYhGux9BCf4RbALXWkiv6X9 vrH+cTe7u4klWYrw1XWEJAtHGtO8RsfmE8SPCIYI3vqcZbmsk73qWje0buwmDgqrZsJc UVCQ== X-Gm-Message-State: AOAM531M3XDF/QkWmEeauynp2NfFLA1jjgaoyjgxr+DMWkvXLODsUX6s EIeO1bVemxEFAjh4mpZZ0XA= X-Received: by 2002:a17:907:8a25:b0:6d7:d59:6912 with SMTP id sc37-20020a1709078a2500b006d70d596912mr4275772ejc.259.1648106754763; Thu, 24 Mar 2022 00:25:54 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id hg11-20020a1709072ccb00b006cee4fb36c7sm770476ejc.64.2022.03.24.00.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:25:54 -0700 (PDT) From: Jakob Koschel To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] spi: spidev: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:25:34 +0100 Message-Id: <20220324072534.63420-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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/spi/spidev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index a5cceca8b82b..2c5e685826ad 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -561,19 +561,20 @@ spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static int spidev_open(struct inode *inode, struct file *filp) { - struct spidev_data *spidev; + struct spidev_data *spidev = NULL, *iter; int status = -ENXIO; mutex_lock(&device_list_lock); - list_for_each_entry(spidev, &device_list, device_entry) { - if (spidev->devt == inode->i_rdev) { + list_for_each_entry(iter, &device_list, device_entry) { + if (iter->devt == inode->i_rdev) { status = 0; + spidev = iter; break; } } - if (status) { + if (!spidev) { pr_debug("spidev: nothing for minor %d\n", iminor(inode)); goto err_find_dev; } base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1