Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp692381ybl; Fri, 16 Aug 2019 02:26:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvflI+u/0hSx4WbHB69JY1PaGePyBS6rDRqXCgvRzl+s2fToP+1mpxixKWLFsfFby0vIa0 X-Received: by 2002:a65:690e:: with SMTP id s14mr7059824pgq.47.1565947573150; Fri, 16 Aug 2019 02:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565947573; cv=none; d=google.com; s=arc-20160816; b=jWy1ycTcf+uiyusyUcacMGOtWN+jyxtyd1EgZS6lyB+o00ukNRXP6uPG5ZjiuWlWZ/ SnwVfNJCBp+oUJDmJ6bcRcZkiSXJlk91kZF4T8F3gfKFZVWUJGQy8hiMxN3j+BpHqyOD ZjUeys/3Sm4XC2d0cd68SpKM/rc+i42fh1zwVm2BNKJfVfG/0CVT65NHDdCp7Tk6YCdS iNxLRsCDhS0HmNVIFMyAI6JOIOtYReJQhg5IRjm4zINt0/GFLwfdP4QS1XrwTj1KytLG PM3r3frK42/OwvzYR5uXfAu/nAbQT7CdkAUNzBXoEXLW/phbJsq3GYoD2qBD2cr6Z5ur C3fw== 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=nxzAYP11S0d/1a3dYYvLWUsgWAZhT+IPIf01ibLHMzA=; b=ZSLtIA4n47pv74J1J64xSQ6Uw4aRm0XPqhrvmiFgAPUFwiJ2a6wSuFtu6URhR18RhN PIobsULdtijcBL19bNoaRHo9bbBZs0ZO61wkozz03KxTkn5urEI74uyVu0syP0b/GA3B lVW2EKu1Oi5Az2vzqWCBPpEvBF5BT98E2+rrvozfnoIupafhXgV7ToPePBY06U2i2302 iwWm457izH+lpWdSJ95xemkzwC/1Ypxwtql8o03VYv8TyJweR5TAO4FJMDJlM00t3x1n ypO5gkPqnk3qPueBKrvX58Fg7YvFXoSM0YNMVAxRxzHhUtBW5B+U3u25kfAenIUl1QbB 6Zsw== 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 v189si3479141pgd.289.2019.08.16.02.25.55; Fri, 16 Aug 2019 02:26:13 -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 S1727122AbfHPJZG (ORCPT + 99 others); Fri, 16 Aug 2019 05:25:06 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50529 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbfHPJZF (ORCPT ); Fri, 16 Aug 2019 05:25:05 -0400 Received: by mail-wm1-f65.google.com with SMTP id v15so3497486wml.0; Fri, 16 Aug 2019 02:25:04 -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=nxzAYP11S0d/1a3dYYvLWUsgWAZhT+IPIf01ibLHMzA=; b=QO8yCch33opuXgmTAPGDbZToVsky87JDx6C5dq0lMyrihIEEYKc0KJ0R9QG8zl7Y5y abESgonhXEJdvseVYKiRVQxuLBEr+Yw3om/K9IBNRw9+QzS9apNDb8ap9YBW1Go5kw0L G3J8tnN2dkVzQda4nfhoeSuI4J5oPGh5w1bjJElAIj1+ThiyrK5xW8HUdIJRac5X6d2w sl7F2+j7Wl9/ZF+sbSKUxm4Cq6U+24LQ6qvEsCUutffe1OJ5FCjmgpIpNurKLU4OGLDL fmtFu/fKA8tzigOY5PC4lPNDTrtZmDE8YFlLCqaZJb0aQwvGHBBVOUOfB5gxb5U6gdnh XK0Q== X-Gm-Message-State: APjAAAVQSyHVQoM1EJjndBDEhufcTZfDw4qIhTZSAI+1vAHl+eGYwH8O VUDx8qZ9LfnYOpXbgvUzXR4= X-Received: by 2002:a1c:4d0c:: with SMTP id o12mr6541900wmh.62.1565947503517; Fri, 16 Aug 2019 02:25:03 -0700 (PDT) Received: from localhost.localdomain (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.googlemail.com with ESMTPSA id q20sm16521138wrc.79.2019.08.16.02.25.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2019 02:25:03 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Sebastian Ott , Gerald Schaefer , "H. Peter Anvin" , Giuseppe Cavallaro , Alexandre Torgue , Matt Porter , Alexandre Bounine , Peter Jones , Bartlomiej Zolnierkiewicz , Cornelia Huck , Alex Williamson , Andrew Murray , Jose Abreu , kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, netdev@vger.kernel.org, x86@kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v2 01/10] PCI: Add define for the number of standard PCI BARs Date: Fri, 16 Aug 2019 12:24:28 +0300 Message-Id: <20190816092437.31846-2-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190816092437.31846-1-efremov@linux.com> References: <20190816092437.31846-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 Code that iterates over all standard PCI BARs typically uses PCI_STD_RESOURCE_END. However, it requires the "unusual" loop condition "i <= PCI_STD_RESOURCE_END" rather than something more standard like "i < PCI_STD_NUM_BARS". This patch adds the definition PCI_STD_NUM_BARS which is equivalent to "PCI_STD_RESOURCE_END + 1" and updates loop conditions to use it. Signed-off-by: Denis Efremov --- drivers/pci/quirks.c | 2 +- include/linux/pci.h | 2 +- include/uapi/linux/pci_regs.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 208aacf39329..02bdf3a0231e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -475,7 +475,7 @@ static void quirk_extend_bar_to_page(struct pci_dev *dev) { int i; - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct resource *r = &dev->resource[i]; if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 9e700d9f9f28..7b9590d5dc2d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -76,7 +76,7 @@ enum pci_mmap_state { enum { /* #0-5: standard PCI resources */ PCI_STD_RESOURCES, - PCI_STD_RESOURCE_END = 5, + PCI_STD_RESOURCE_END = PCI_STD_RESOURCES + PCI_STD_NUM_BARS - 1, /* #6: expansion ROM resource */ PCI_ROM_RESOURCE, diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f28e562d7ca8..68b571d491eb 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -34,6 +34,7 @@ * of which the first 64 bytes are standardized as follows: */ #define PCI_STD_HEADER_SIZEOF 64 +#define PCI_STD_NUM_BARS 6 /* Number of standard BARs */ #define PCI_VENDOR_ID 0x00 /* 16 bits */ #define PCI_DEVICE_ID 0x02 /* 16 bits */ #define PCI_COMMAND 0x04 /* 16 bits */ -- 2.21.0