Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4606929ybe; Mon, 16 Sep 2019 15:22:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuy5TU1QGwvoaSg9lbjaXnOBCdOAnfBGDEDUUfJeL726PjZ1Bx/waMjIscLblzSPj6h6B8 X-Received: by 2002:a05:6402:65a:: with SMTP id u26mr1627503edx.86.1568672568141; Mon, 16 Sep 2019 15:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568672568; cv=none; d=google.com; s=arc-20160816; b=yGGSmngzkyegxmyqZ1O6yoTsaL8kyBmOO/VBIkG7muxOez3/f8deZSLsqlYOlq4CPd RWqGRFQom7LBIJuTFikwOt/0cY0eB+QqiV4FtSTxNJzSv0faqMJga/1weBmvwmOGWdNh HURwSQJ8/XsIxKS7FPGzsX3o3BoCImfxG4GStPIumzOm+NzEwFV1rm2CH2N+QG+/Ih1D ZU3D0yacyrFfoSfCPgYVnBYamTub4ShKxKU1YatG2L0RBDct1RPXR2NE5uG2x6A6v5Ys 7wsE0jhdyIn4nirBwxzRZKOCKJA4eR6cY/eVxTlEaAagA89kSDjCpXFzUgAzzgNlYUhd eTVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VQgdi9RT91f00lILEI11lVCIdYnGLkjukNZtLishIZk=; b=dXLo0rON+PbS7DuCDfkCxDSODnTjXUxvivn4Na1OnknIrsY5Vnelp13iYLBQJ36XT0 gDwP68teQKNyQOvvH+HXSkA+5NfdLhbpFLIZegfU3Ji9azb+gRkIG8e2o+ids3ImClPN WL8nthWxl64PUNASjFKsQgXFPTwsdlFWWocQ3qxDWKI4Nj5FNPlvyxrTTnCZAwGZJ1Yh x7BDEGTeoHXPacgyF4FyzhPlmyXAVgJW11B4Wg5s1moWXWttz5hgSAbnRXlaUXXaqKpg EXfbAmIFh7OWeeh7MsMHG3uMcuwAjqJIAP25Cdn/D1ncoNbKIiXIVMvZTYCUtKb+MyqF kNKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si126268ejr.360.2019.09.16.15.22.24; Mon, 16 Sep 2019 15:22:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403882AbfIPUoP (ORCPT + 99 others); Mon, 16 Sep 2019 16:44:15 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38762 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403842AbfIPUoN (ORCPT ); Mon, 16 Sep 2019 16:44:13 -0400 Received: by mail-wm1-f67.google.com with SMTP id o184so698692wme.3; Mon, 16 Sep 2019 13:44:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VQgdi9RT91f00lILEI11lVCIdYnGLkjukNZtLishIZk=; b=RDN9MmJw1VqMnj4kwfg57e/T64vOGq6XRngILGbD35TWUowyfMccbb2Z24YDOyrG3F SL6eibZFnXlMJ6WHzG6q8GnCBfywda7bvQhqWAv/Yudu8FUU/8FBNcHr6Rmc0L5BWmnu Y6YeCMDeEpg8vhJXtdlFNT6r23YfvUMYRaUJPLyo+zUVwWmHUIX+S5H0Sd1IxBXnWT17 /SFBPiNaocSSyu5GhvouT2vX6MOplQsMEZ6OEJ4J86qiRdW68SbKc0LorubBSJVwT90n aMvb6j8dHAKKSDxkEwdhSgClraVXi/ouHruNUGns196nMKU/ssv5RMeRfAKzmTkiXomI MytQ== X-Gm-Message-State: APjAAAVTQqpvs1/XXQeLCLIUCMeRWKnmGDlaEf/mvuySCtQ94cCc3LeN 76AMA0DmTxfxJL0uEZaBsNI= X-Received: by 2002:a1c:a942:: with SMTP id s63mr665037wme.152.1568666649828; Mon, 16 Sep 2019 13:44:09 -0700 (PDT) Received: from black.home (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id x6sm231437wmf.38.2019.09.16.13.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:09 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , Kishon Vijay Abraham I , Lorenzo Pieralisi Subject: [PATCH v3 05/26] misc: pci_endpoint_test: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:37 +0300 Message-Id: <20190916204158.6889-6-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190916204158.6889-1-efremov@linux.com> References: <20190916204158.6889-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To iterate through all possible BARs, loop conditions refactored to the *number* of BARs "i < PCI_STD_NUM_BARS", instead of the index of the last valid BAR "i <= BAR_5". This is more idiomatic C style and allows to avoid the fencepost error. Array definitions changed to PCI_STD_NUM_BARS where appropriate. Cc: Kishon Vijay Abraham I Cc: Lorenzo Pieralisi Signed-off-by: Denis Efremov --- drivers/misc/pci_endpoint_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 6e208a060a58..a5e317073d95 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -94,7 +94,7 @@ enum pci_barno { struct pci_endpoint_test { struct pci_dev *pdev; void __iomem *base; - void __iomem *bar[6]; + void __iomem *bar[PCI_STD_NUM_BARS]; struct completion irq_raised; int last_irq; int num_irqs; @@ -687,7 +687,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, if (!pci_endpoint_test_request_irq(test)) goto err_disable_irq; - for (bar = BAR_0; bar <= BAR_5; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { base = pci_ioremap_bar(pdev, bar); if (!base) { @@ -740,7 +740,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, ida_simple_remove(&pci_endpoint_test_ida, id); err_iounmap: - for (bar = BAR_0; bar <= BAR_5; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (test->bar[bar]) pci_iounmap(pdev, test->bar[bar]); } @@ -771,7 +771,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) misc_deregister(&test->miscdev); kfree(misc_device->name); ida_simple_remove(&pci_endpoint_test_ida, id); - for (bar = BAR_0; bar <= BAR_5; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (test->bar[bar]) pci_iounmap(pdev, test->bar[bar]); } -- 2.21.0