Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2755312ybl; Sun, 11 Aug 2019 08:11:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwalJ18rwmw7Ng3/l7MjBRTqa5yEcRLkiyThb42Fx8Koc/oOEGvgOLpwp5GRCT3OkqsLO3Q X-Received: by 2002:aa7:85d6:: with SMTP id z22mr5570741pfn.262.1565536264989; Sun, 11 Aug 2019 08:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565536264; cv=none; d=google.com; s=arc-20160816; b=LqyGI5LTv0aFQFicdl9JnKiwyNd+zCccX86feKUhBneVHBFhzM9v177s1kBX7YfBmb /AWPCK8lciAAjZdSSEzXVT2v8Q1DQbDKxxBDkKZa6gSoL7tBDYJ62CoPX/W4tzDw4wng RiS68tQtO3G8h/QT7kjOO5KgY6QXLW1WD4JzZQCHcnkOWvj1PGtwym5zXisX+OBRbZ4X doxp31KbXgPNRuCS8gjpkU3DNlui1tJDllFO65aJmWSmyn/Vo9qDUNXqxsVebxXfB6FB rtZX2toPZg2wUH+CsGLioG0JslaTkIMJBNj5OA7WeayYtIU3jKhbVYLcgd4mc5Rl7G9H Hkpw== 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=iPNNvJU4DvdLzLJ5awsX5A0LO7JV7WokGq58mBMBAwJ0/qnVO9FEpWv4i4Uv5xqHeT QFzKZFU6fzJtezmqKAOn6MtmF/4Vp8K+KgY1dduR9oy9dzLMifRZHvQvrn9ub6Vm1PXW lpR1tMOnSEpHNqpQQzmXifnH1B+wgBpIahACVFGllNpeXSRYOEfM/AyrXv839D8Xcoot PO59vjRd3GyyYl8UsmZ7J2Vwh6SHoiGV3X1UBHfh7Hz0TacFIoXdjl9SgSZGpNg4i5Xg qXFpXCm6eRpbVDii6C9CBkYH9wMGsIi7SHX2TeGZOQ2IPYkt8dgsC6iRXJaDA3e9gEWF +rMw== 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 s31si19821763plb.362.2019.08.11.08.10.14; Sun, 11 Aug 2019 08:11:04 -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 S1726602AbfHKPId (ORCPT + 99 others); Sun, 11 Aug 2019 11:08:33 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45433 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfHKPIc (ORCPT ); Sun, 11 Aug 2019 11:08:32 -0400 Received: by mail-wr1-f67.google.com with SMTP id q12so12232034wrj.12; Sun, 11 Aug 2019 08:08:30 -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=tERWaxWvAJHPhNnSUfvH2TV0d5qSZRIgCjVz6UZokXxJqBTytjsuS/M6JRAO4kzdf+ bJy+sYgFdnSsj5q2c/HndwoO4nHSsckPH0QmpvSIYhM+Yv0QjlJ+MhmbMPi/Uvxdg/Nu 2pw0L7kZQyR9wFCg7qKRnus4l+XE+V6zefnl+ro5BQ/Ua4idwnVhE4b7tSrA70oDAmNy WRSlh0Ezikj0WaCQQCzSV2U40yIy+QqaWgZczB+aEtjHnF29V5I+rGsxhpHYDWEUpDi3 KyiqDiyC3ZTO7xB9q9Xc3uO86YBWQOMOoJEoUjnMigTb3bAjh13Xg4Q1I64+RCtqp+Kd NeuA== X-Gm-Message-State: APjAAAX/i4HZVmLZwBdi3byVL/gts2DL2ZrwXy8lYFpKuMz/fbh/1X7P MCkmCs88yt8EKv+nAOTM4iU= X-Received: by 2002:adf:f186:: with SMTP id h6mr34996098wro.274.1565536109482; Sun, 11 Aug 2019 08:08:29 -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 y16sm227049408wrg.85.2019.08.11.08.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 08:08:29 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , Sebastian Ott , Gerald Schaefer , "H. Peter Anvin" , Giuseppe Cavallaro , Alexandre Torgue , Matt Porter , Alexandre Bounine , Peter Jones , Bartlomiej Zolnierkiewicz , Cornelia Huck , Alex Williamson , kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, netdev@vger.kernel.org, x86@kernel.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] PCI: Add define for the number of standard PCI BARs Date: Sun, 11 Aug 2019 18:07:56 +0300 Message-Id: <20190811150802.2418-2-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190811150802.2418-1-efremov@linux.com> References: <20190811150802.2418-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