Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4609999ybe; Mon, 16 Sep 2019 15:26:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyi+ji5fxjDhXB5Q4MLQvotssJ90ksJ4lOuTrJXSJLRhIjG1Uwgs3cXG2OMtaSoUvAp4Oij X-Received: by 2002:a50:cc4d:: with SMTP id n13mr1628006edi.5.1568672807606; Mon, 16 Sep 2019 15:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568672807; cv=none; d=google.com; s=arc-20160816; b=M+QYpHlR1p8CV+p4RWClrFHEbvgJAYP0Uk3aoQW85t/krN3ZzHtym9hmp3CP4Quef/ ApPoRW33Gbe1Nlu4FtdWKiI3VzerUSKHlh0klpNuip6D8yAwCS6EiHvUqDXEt5Te1X85 efG+GlZxlFzwdHe361vpA1uZZ4vnAWzfM04IukMaWPCSAbPbI/p+aY0z7y2yMAy8KKqa vL+C/gVJhAOcamLbcGVJwgKX9tOdbDuNo+gtSkfKoLhHNyd/5+eIXEbMSR+MLMshkmq8 2FBapuPetwZjd3otKJhdnL3MFN81EU49jF4MkRYpBMuVr8IqlwxLaOPkBi8XSPWIqVsM Jr4g== 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=2nJMFsxH3rGbm7OGTrOSwfsrpZrcICAXeTBwaXsuQJg=; b=NHjmy6BZMkZOlY8dCzgP0gQKna7mIMYrGoGy9fPt70bEhdw1CvOBNPjEFamjvKki4s XaUDio96tZ+Lvy3FGuV3V/+RgTOEj3wcHWPolbeFX0KGBoM9PmBlcA/+iq/GO6InBYC0 tX4qVo9tbqkYdoyvxv3loGzk1ZRjESFsPR+uSZTHfnR2e4GnTsdSX/sFO0ecg5c55JR1 fbXiFKyCQm+tjZ42RFaNB5E5NyLGAyi914gWDkLgA2CUtHSgYAhvwjuJeUAcnGpr31/u 6N+aw+XzDmHyfg1xRQD7yXfxFLJQg1N3VF2lyq9u6ZdJD0SAhlythOSlizZk+jyc/AwC O2SA== 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 ci20si133035ejb.262.2019.09.16.15.26.23; Mon, 16 Sep 2019 15:26:47 -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 S2403931AbfIPUoW (ORCPT + 99 others); Mon, 16 Sep 2019 16:44:22 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53883 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403881AbfIPUoQ (ORCPT ); Mon, 16 Sep 2019 16:44:16 -0400 Received: by mail-wm1-f67.google.com with SMTP id i16so779220wmd.3; Mon, 16 Sep 2019 13:44:14 -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=2nJMFsxH3rGbm7OGTrOSwfsrpZrcICAXeTBwaXsuQJg=; b=eEPWJs0iftYMP7xXi7ZhppBM5NR4xHurpptq6dJKYfzB9XzmxU6NgaQ2xnjI2hfDPF tv7HpLC7JNqdGQ/yxYG+h2sNPIZTH52j8bNi7+ZAVB+7FQG0ht8vHO60L3ItQekbqUXM 0R5nRkfVFuqShfbWD27PVBed95Fa+dXtaTIT6mbmM5SbgKNuq3r7MCKk0NPEFthyvJQN pLB3CtaSEi/fFkf0AsApZTBk0IzA3deqyY+xPh8pr7LAgI+BWI1rFN1rYlKLBdi/AVt3 c4LH0YgME0hY8i0/VdWYdeU1HS1eM0zF//ylthgJENX2OfFs/flXYdrJP3hTMrEeJjdu UD3w== X-Gm-Message-State: APjAAAX6/Rj8WfQrafPEL2WLVT8nRfrdBh7cN7ipaCx4s9CWZsfR1ix6 48Orh5eqFPJBoZC0jyCZ5z7Wsp+NFS0= X-Received: by 2002:a1c:1d84:: with SMTP id d126mr683892wmd.58.1568666654249; Mon, 16 Sep 2019 13:44:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:13 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner Subject: [PATCH v3 07/26] x86/PCI: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:39 +0300 Message-Id: <20190916204158.6889-8-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 Refactor loops to use idiomatic C style and avoid the fencepost error of using "i < PCI_STD_RESOURCE_END" when "i <= PCI_STD_RESOURCE_END" is required, e.g., commit 2f686f1d9bee ("PCI: Correct PCI_STD_RESOURCE_END usage"). To iterate through all possible BARs, loop conditions changed to the *number* of BARs "i < PCI_STD_NUM_BARS", instead of the index of the last valid BAR "i <= PCI_STD_RESOURCE_END" or PCI_ROM_RESOURCE. Cc: H. Peter Anvin Cc: Thomas Gleixner Signed-off-by: Denis Efremov --- arch/x86/pci/common.c | 2 +- arch/x86/pci/intel_mid_pci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 9acab6ac28f5..1e59df041456 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -135,7 +135,7 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev) * resource so the kernel doesn't attempt to assign * it later on in pci_assign_unassigned_resources */ - for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { bar_r = &dev->resource[bar]; if (bar_r->start == 0 && bar_r->end != 0) { bar_r->flags = 0; diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c index 43867bc85368..00c62115f39c 100644 --- a/arch/x86/pci/intel_mid_pci.c +++ b/arch/x86/pci/intel_mid_pci.c @@ -382,7 +382,7 @@ static void pci_fixed_bar_fixup(struct pci_dev *dev) PCI_DEVFN(2, 2) == dev->devfn) return; - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { pci_read_config_dword(dev, offset + 8 + (i * 4), &size); dev->resource[i].end = dev->resource[i].start + size - 1; dev->resource[i].flags |= IORESOURCE_PCI_FIXED; -- 2.21.0