From patchwork Fri Sep 27 23:43:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11165247 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14DFB13B1 for ; Fri, 27 Sep 2019 23:43:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E602721841 for ; Fri, 27 Sep 2019 23:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728305AbfI0XnQ (ORCPT ); Fri, 27 Sep 2019 19:43:16 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35327 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbfI0XnQ (ORCPT ); Fri, 27 Sep 2019 19:43:16 -0400 Received: by mail-lf1-f67.google.com with SMTP id w6so3116459lfl.2; Fri, 27 Sep 2019 16:43:13 -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=c8uGLij7T5Lhd9NNM8IRpienFCfZLI1fF2YsMfwjMb0=; b=nGEy3BShGtH9jG0mH+ZtDfICSzXbZwOQWP3jeLcW93g20Qkt/JnkUI6i/1tsHCXtQq 5mAoANpqa1BecDWxVjyr6VZkOS0xU69VvudDeerrU1SJlAjtkmfBqoIUNfOAdtffnEhE muVvtwrXJZ7q+f+tGWt3q6xnFFSEFJlcmZlPS7sAYm2L92Hy9g9Q1tHwwOLte1K3e/KJ qg+R2okbKGnfOEB4wF3h91EF9ey9x2YUhje6aSw/jaVb+sXU1Hzj+IbrdnOVCoISAv9c bpCTkxGJVqijAc0U22vuNZ7U1So4HNUfhva14qO2qxIhHPiMl7k8XH9s0T4bIuk7ufse LUUg== X-Gm-Message-State: APjAAAWaqLjk8krkp7T8bzcPm61xAYWxTdyPgbmKapb5dRQr/WVEYTiC qEUt/KnkRFuDjUHlq94YDZNuey8rsTY= X-Google-Smtp-Source: APXvYqxaiyRdOlpBwWGF862QfV4eTAG1q+uwD8zL+weLda64/duQKMgTc/QRXQANLb7+8tTLId6QQQ== X-Received: by 2002:ac2:4c8f:: with SMTP id d15mr4785336lfl.74.1569627792625; Fri, 27 Sep 2019 16:43:12 -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 b67sm788812ljf.5.2019.09.27.16.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 16:43:12 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org, x86@kernel.org, linux-s390@vger.kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RESEND v3 01/26] PCI: Add define for the number of standard PCI BARs Date: Sat, 28 Sep 2019 02:43:08 +0300 Message-Id: <20190927234308.23935-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190916204158.6889-3-efremov@linux.com> References: <20190916204158.6889-3-efremov@linux.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". 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. The magic constant (6) is also replaced with new define PCI_STD_NUM_BARS. Signed-off-by: Denis Efremov --- drivers/pci/pci-sysfs.c | 4 ++-- drivers/pci/pci.c | 13 +++++++------ drivers/pci/proc.c | 4 ++-- drivers/pci/quirks.c | 4 ++-- include/linux/pci.h | 2 +- include/uapi/linux/pci_regs.h | 1 + 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 965c72104150..3e26b8e03bd5 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1257,7 +1257,7 @@ static void pci_remove_resource_files(struct pci_dev *pdev) { int i; - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; @@ -1328,7 +1328,7 @@ static int pci_create_resource_files(struct pci_dev *pdev) int retval; /* Expose the PCI resources from this device as files */ - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { /* skip empty resources */ if (!pci_resource_len(pdev, i)) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1b27b5af3d55..7d543986026b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -674,7 +674,7 @@ struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res) { int i; - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct resource *r = &dev->resource[i]; if (r->start && resource_contains(r, res)) @@ -3768,7 +3768,7 @@ void pci_release_selected_regions(struct pci_dev *pdev, int bars) { int i; - for (i = 0; i < 6; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) if (bars & (1 << i)) pci_release_region(pdev, i); } @@ -3779,7 +3779,7 @@ static int __pci_request_selected_regions(struct pci_dev *pdev, int bars, { int i; - for (i = 0; i < 6; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) if (bars & (1 << i)) if (__pci_request_region(pdev, i, res_name, excl)) goto err_out; @@ -3827,7 +3827,7 @@ EXPORT_SYMBOL(pci_request_selected_regions_exclusive); void pci_release_regions(struct pci_dev *pdev) { - pci_release_selected_regions(pdev, (1 << 6) - 1); + pci_release_selected_regions(pdev, (1 << PCI_STD_NUM_BARS) - 1); } EXPORT_SYMBOL(pci_release_regions); @@ -3846,7 +3846,8 @@ EXPORT_SYMBOL(pci_release_regions); */ int pci_request_regions(struct pci_dev *pdev, const char *res_name) { - return pci_request_selected_regions(pdev, ((1 << 6) - 1), res_name); + return pci_request_selected_regions(pdev, + ((1 << PCI_STD_NUM_BARS) - 1), res_name); } EXPORT_SYMBOL(pci_request_regions); @@ -3868,7 +3869,7 @@ EXPORT_SYMBOL(pci_request_regions); int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name) { return pci_request_selected_regions_exclusive(pdev, - ((1 << 6) - 1), res_name); + ((1 << PCI_STD_NUM_BARS) - 1), res_name); } EXPORT_SYMBOL(pci_request_regions_exclusive); diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index fe7fe678965b..cb61ec2c24e8 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -248,13 +248,13 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) } /* Make sure the caller is mapping a real resource for this device */ - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (dev->resource[i].flags & res_bit && pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS)) break; } - if (i >= PCI_ROM_RESOURCE) + if (i >= PCI_STD_NUM_BARS) return -ENODEV; if (fpriv->mmap_state == pci_mmap_mem && diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 44c4ae1abd00..998454b0ae8d 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) { @@ -1810,7 +1810,7 @@ static void quirk_alder_ioapic(struct pci_dev *pdev) * The next five BARs all seem to be rubbish, so just clean * them out. */ - for (i = 1; i < 6; i++) + for (i = 1; i < PCI_STD_NUM_BARS; i++) memset(&pdev->resource[i], 0, sizeof(pdev->resource[i])); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic); diff --git a/include/linux/pci.h b/include/linux/pci.h index 82e4cd1b7ac3..cf7d16305243 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 */ From patchwork Mon Sep 16 20:41:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147751 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D44914ED for ; Mon, 16 Sep 2019 20:43:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 755E920830 for ; Mon, 16 Sep 2019 20:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391444AbfIPUni (ORCPT ); Mon, 16 Sep 2019 16:43:38 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37184 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730610AbfIPUni (ORCPT ); Mon, 16 Sep 2019 16:43:38 -0400 Received: by mail-wr1-f66.google.com with SMTP id i1so843431wro.4; Mon, 16 Sep 2019 13:43:36 -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=oEvxZvssX49R5a8dabCLJlXPjptDKkJzN4UZVHUANFI=; b=CHBypgUHaxf7cVBalNuSWPc2byC/r6Y5yDzGoGRIHv7tSnV3UT6tLe0c0xdiwKGbGo QkZpKz7FzejCnmY/WKqaCMLv82YbL+QFy1BRo5hvBEl2yjburhHJV124V6vE4LfZXTon ZS8CgNMchSN2QKEI2ocWoHeS/bIPwJw8ugXbrN/RXJw1d/Uvkub1i8zKF8lNwNx72cCt S/iX+ztSWK5oXs+K26YFnHp3GYBAiCRuNIRidwWjQMaQK+3zCsIvdL8MQsGXL6EjOv3r Om12OeMe8shwC9psKl215IB7Pa76t20tWn0CIhgCjQ919Y0Bb1RIRJ/Ndh/nuZbkuaK+ /5kg== X-Gm-Message-State: APjAAAUYsBlz4KfQzRwJCPjVgfBpMD9WyW4AfluFwTy0SRu6HpUJLpQb IuWzzZv49zQ+fLj9uwzXLPk= X-Google-Smtp-Source: APXvYqyy42MRiZs7nxgMyo+9sMwrImohVM3ON2Adp8kT5iGWbgOjB+CDnQUW+D/FFxhanpK6U23gHQ== X-Received: by 2002:a05:6000:105:: with SMTP id o5mr203431wrx.51.1568666616192; Mon, 16 Sep 2019 13:43:36 -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.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:43:35 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-hyperv@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin Subject: [PATCH v3 02/26] PCI: hv: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:34 +0300 Message-Id: <20190916204158.6889-3-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Replace the magic constant (6) with define PCI_STD_NUM_BARS representing the number of PCI BARs. Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Sasha Levin Signed-off-by: Denis Efremov Reviewed-by: Haiyang Zhang --- drivers/pci/controller/pci-hyperv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 40b625458afa..1665c23b649f 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -307,7 +307,7 @@ struct pci_bus_relations { struct pci_q_res_req_response { struct vmpacket_descriptor hdr; s32 status; /* negative values are failures */ - u32 probed_bar[6]; + u32 probed_bar[PCI_STD_NUM_BARS]; } __packed; struct pci_set_power { @@ -503,7 +503,7 @@ struct hv_pci_dev { * What would be observed if one wrote 0xFFFFFFFF to a BAR and then * read it back, for each of the BAR offsets within config space. */ - u32 probed_bar[6]; + u32 probed_bar[PCI_STD_NUM_BARS]; }; struct hv_pci_compl { @@ -1327,7 +1327,7 @@ static void survey_child_resources(struct hv_pcibus_device *hbus) * so it's sufficient to just add them up without tracking alignment. */ list_for_each_entry(hpdev, &hbus->children, list_entry) { - for (i = 0; i < 6; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) dev_err(&hbus->hdev->device, "There's an I/O BAR in this list!\n"); @@ -1401,7 +1401,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) /* Pick addresses for the BARs. */ do { list_for_each_entry(hpdev, &hbus->children, list_entry) { - for (i = 0; i < 6; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { bar_val = hpdev->probed_bar[i]; if (bar_val == 0) continue; @@ -1558,7 +1558,7 @@ static void q_resource_requirements(void *context, struct pci_response *resp, "query resource requirements failed: %x\n", resp->status); } else { - for (i = 0; i < 6; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { completion->hpdev->probed_bar[i] = q_res_req->probed_bar[i]; } From patchwork Mon Sep 16 20:41:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147753 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9857414ED for ; Mon, 16 Sep 2019 20:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80BA720830 for ; Mon, 16 Sep 2019 20:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391485AbfIPUoE (ORCPT ); Mon, 16 Sep 2019 16:44:04 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45786 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730600AbfIPUoD (ORCPT ); Mon, 16 Sep 2019 16:44:03 -0400 Received: by mail-wr1-f68.google.com with SMTP id r5so776480wrm.12; Mon, 16 Sep 2019 13:44:02 -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=gi9kNDzuHd/emIWQ69sBkpIiSLmOA3ELluXth5M4W3s=; b=FcKmtX4WiXdbOK2hxUpbqr4ysxnRdSjGXDj01g/3TkXQJhXpZP1B70QywuydOuL+Qu 13msJK18W1XR/50KojUkeOA9IyiSE/fZLfeZ1cZYXskDU2lRiDgS2m8hJEha2zB3WjCE 9DWja0AkoO+ULdWxw+n/OCUhpqWybOiusO8n33jk91x0JsMlyS/ZVHRcAM1mHCGFzKlF qEYR3Fo5RpXnfXEgshEMlMJdDA5SXNb80jIxMfRBzBSVA2w6seNQ0tkMRFdEvJn+QDbN 0bqTWMccuHBfMMUS1nadVkFaXZ/HlTv5sZ8R6bu3NXOvYmx6hzFsKd71yU1/qzjATZC1 de7g== X-Gm-Message-State: APjAAAXskPoQTN9JEojdpnG/99/s94Dqgxw25lbutEtCaReRqRFZKxHE 21JUNZI+M3wdGlVMKidbSb8= X-Google-Smtp-Source: APXvYqxD8CmKKNxnq3M4FD4lAdtntmTgTM/ruEOVYXaPnVSDVDv3Ox3D5WfDzWJKyU38l/6npgrhBA== X-Received: by 2002:a5d:6a06:: with SMTP id m6mr210072wru.190.1568666641674; Mon, 16 Sep 2019 13:44:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:01 -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 , Gustavo Pimentel Subject: [PATCH v3 03/26] PCI: dwc: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:35 +0300 Message-Id: <20190916204158.6889-4-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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 Cc: Gustavo Pimentel Signed-off-by: Denis Efremov Acked-by: Gustavo Pimentel --- drivers/pci/controller/dwc/pci-dra7xx.c | 2 +- drivers/pci/controller/dwc/pci-layerscape-ep.c | 2 +- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/dwc/pcie-designware-plat.c | 2 +- drivers/pci/controller/dwc/pcie-designware.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 4234ddb4722f..b20651cea09f 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -353,7 +353,7 @@ static void dra7xx_pcie_ep_init(struct dw_pcie_ep *ep) struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); enum pci_barno bar; - for (bar = BAR_0; bar <= BAR_5; bar++) + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); dra7xx_pcie_enable_wrapper_interrupts(dra7xx); diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index be61d96cc95e..c84218d8ffd3 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -57,7 +57,7 @@ static void ls_pcie_ep_init(struct dw_pcie_ep *ep) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); enum pci_barno bar; - for (bar = BAR_0; bar <= BAR_5; bar++) + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); } diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c b/drivers/pci/controller/dwc/pcie-artpec6.c index d00252bd8fae..9e2482bd7b6d 100644 --- a/drivers/pci/controller/dwc/pcie-artpec6.c +++ b/drivers/pci/controller/dwc/pcie-artpec6.c @@ -422,7 +422,7 @@ static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) artpec6_pcie_wait_for_phy(artpec6_pcie); artpec6_pcie_set_nfts(artpec6_pcie); - for (bar = BAR_0; bar <= BAR_5; bar++) + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); } diff --git a/drivers/pci/controller/dwc/pcie-designware-plat.c b/drivers/pci/controller/dwc/pcie-designware-plat.c index b58fdcbc664b..73646b677aff 100644 --- a/drivers/pci/controller/dwc/pcie-designware-plat.c +++ b/drivers/pci/controller/dwc/pcie-designware-plat.c @@ -70,7 +70,7 @@ static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep) struct dw_pcie *pci = to_dw_pcie_from_ep(ep); enum pci_barno bar; - for (bar = BAR_0; bar <= BAR_5; bar++) + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) dw_pcie_ep_reset_bar(pci, bar); } diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index ffed084a0b4f..7e0526bd71ad 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -205,7 +205,7 @@ struct dw_pcie_ep { phys_addr_t phys_base; size_t addr_size; size_t page_size; - u8 bar_to_atu[6]; + u8 bar_to_atu[PCI_STD_NUM_BARS]; phys_addr_t *outbound_addr; unsigned long *ib_window_map; unsigned long *ob_window_map; From patchwork Mon Sep 16 20:41:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147755 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5495113BD for ; Mon, 16 Sep 2019 20:44:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CEBF206A4 for ; Mon, 16 Sep 2019 20:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403849AbfIPUoJ (ORCPT ); Mon, 16 Sep 2019 16:44:09 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40274 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403842AbfIPUoI (ORCPT ); Mon, 16 Sep 2019 16:44:08 -0400 Received: by mail-wm1-f65.google.com with SMTP id b24so687375wmj.5; Mon, 16 Sep 2019 13:44:07 -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=35Le1CuHRQyVF/cByw2yYN48BkYqEm/VqIIyyf0DRl4=; b=B+dLal9Z/qIruAwH40UbKUUu/gDCp6z1+Rf9r090hUkENBdmWM4X7k7YF+zSF6m6aB OTugm8Va8BEVKYT3VqWJlzFaKx2qX0qomJGQPBXo3/VHb3ABnx5N45KRpuY7LHgGUa4A +kTX2l2Ptvi9MEk8X/iA9iJy53cvHuIX9e05zO9Z3tjyI97nyDJjVHYtv6l6iPueB5zC pKH5cjeDbrp2fdaXm1a/1AI8JwFYbtFQOBpEa2CYtR6JVKM5RLJuORUOs/GorSf3N1FB iyWFyLEG43fJbvLpMgmgAUbhlC/aMJxXLo3SEKKdGUT7FvtOzWJKb7i0ewFtDBw1VbFV Nyig== X-Gm-Message-State: APjAAAVk6b8j0epPVcy0BnJQ0wkjxmxX19zxdj4LNIAJlDDlSVuYHty6 VYvq8N3A/0q3cyj4cxHEMdE= X-Google-Smtp-Source: APXvYqzq7sPF6D7wniXMauABS31yabJspsf0fMDPngm0w8h5Zpukx77o0z1P8ruvWjMvSdZv8jFfCQ== X-Received: by 2002:a1c:f917:: with SMTP id x23mr687011wmh.101.1568666646746; Mon, 16 Sep 2019 13:44:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:06 -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 04/26] PCI: endpoint: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:36 +0300 Message-Id: <20190916204158.6889-5-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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/pci/endpoint/functions/pci-epf-test.c | 10 +++++----- include/linux/pci-epc.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 1cfe3687a211..5d74f81ddfe4 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -44,7 +44,7 @@ static struct workqueue_struct *kpcitest_workqueue; struct pci_epf_test { - void *reg[6]; + void *reg[PCI_STD_NUM_BARS]; struct pci_epf *epf; enum pci_barno test_reg_bar; struct delayed_work cmd_handler; @@ -377,7 +377,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf) cancel_delayed_work(&epf_test->cmd_handler); pci_epc_stop(epc); - for (bar = BAR_0; bar <= BAR_5; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { epf_bar = &epf->bar[bar]; if (epf_test->reg[bar]) { @@ -400,7 +400,7 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) epc_features = epf_test->epc_features; - for (bar = BAR_0; bar <= BAR_5; bar += add) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar += add) { epf_bar = &epf->bar[bar]; /* * pci_epc_set_bar() sets PCI_BASE_ADDRESS_MEM_TYPE_64 @@ -450,7 +450,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) } epf_test->reg[test_reg_bar] = base; - for (bar = BAR_0; bar <= BAR_5; bar += add) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar += add) { epf_bar = &epf->bar[bar]; add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1; @@ -478,7 +478,7 @@ static void pci_epf_configure_bar(struct pci_epf *epf, bool bar_fixed_64bit; int i; - for (i = BAR_0; i <= BAR_5; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { epf_bar = &epf->bar[i]; bar_fixed_64bit = !!(epc_features->bar_fixed_64bit & (1 << i)); if (bar_fixed_64bit) diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index f641badc2c61..56f1846b9d39 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -117,7 +117,7 @@ struct pci_epc_features { unsigned int msix_capable : 1; u8 reserved_bar; u8 bar_fixed_64bit; - u64 bar_fixed_size[BAR_5 + 1]; + u64 bar_fixed_size[PCI_STD_NUM_BARS]; size_t align; }; From patchwork Mon Sep 16 20:41:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147757 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94F9013BD for ; Mon, 16 Sep 2019 20:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E387206A4 for ; Mon, 16 Sep 2019 20:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403863AbfIPUoN (ORCPT ); Mon, 16 Sep 2019 16:44:13 -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-Google-Smtp-Source: APXvYqwSCKf2jDSGvpyiWIOrkHIQoWSHUpohLQAA2EOc95iW0E/vOzyutjgC3S4E89sCHpvuJ/Xaeg== 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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]); } From patchwork Mon Sep 16 20:41:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147759 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8285A13BD for ; Mon, 16 Sep 2019 20:44:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EB5520644 for ; Mon, 16 Sep 2019 20:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403897AbfIPUoS (ORCPT ); Mon, 16 Sep 2019 16:44:18 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39957 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403869AbfIPUoQ (ORCPT ); Mon, 16 Sep 2019 16:44:16 -0400 Received: by mail-wr1-f65.google.com with SMTP id l3so819726wru.7; Mon, 16 Sep 2019 13:44:12 -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=biVa5TWgIH4FdyTR1jPZk5xG6z3f1lKwc4R/y5Vwp40=; b=neCadqbV+6Ucydna6nqAAffsAuEt2stH5cs3BuITYcqvWsfUnkcIc2qjRcyW2D9gBt dA1W7HfALC21KSmRHQTF8Ea+0UnKrxxC6NfaYvY6AhzdyTY4nvAWI+KpX2Ra4gVKEKE/ ZmFfzE5qZ8vt2pTsieYSx6Kylz/bY+yWe50YVNJlekIK9r+5UHlR7RrWXQCfXL4hWNny 67Vckwid//pzBPptJqb0T6DpFUJW5ekjK/3RP4AKjj4m1G/parVGu2xWuHYFx2k0K1Nd 9m+1DK+kWFTbiB77ncwvZTkxQ47TIWXJba07xpcK9VXEREUjm2P4l9ZQz0cHS3n/7v9L S3/A== X-Gm-Message-State: APjAAAV2WZXyEIxSHlgfvODfiGkPuNLfSqY+4kufsC5T2fmvq0k8jH1y 2h6/O2FhIu9LSmO9/IVY8c4= X-Google-Smtp-Source: APXvYqwQ+Y6pjVCuDeC+MNuztamBqM3ZAsuyCiViX+t2NCMqnz7fV09FxtTDS87WKdHM68MP9j2KfA== X-Received: by 2002:adf:e7c2:: with SMTP id e2mr157281wrn.319.1568666652077; Mon, 16 Sep 2019 13:44:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:11 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-s390@vger.kernel.org, Sebastian Ott , Gerald Schaefer Subject: [PATCH v3 06/26] s390/pci: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:38 +0300 Message-Id: <20190916204158.6889-7-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove local definition PCI_BAR_COUNT for the number of PCI BARs and use global one PCI_STD_NUM_BARS instead. Acked-by: Sebastian Ott Cc: Gerald Schaefer Signed-off-by: Denis Efremov --- arch/s390/include/asm/pci.h | 5 +---- arch/s390/include/asm/pci_clp.h | 6 +++--- arch/s390/pci/pci.c | 16 ++++++++-------- arch/s390/pci/pci_clp.c | 6 +++--- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index a2399eff84ca..3a06c264ea53 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -2,9 +2,6 @@ #ifndef __ASM_S390_PCI_H #define __ASM_S390_PCI_H -/* must be set before including pci_clp.h */ -#define PCI_BAR_COUNT 6 - #include #include #include @@ -138,7 +135,7 @@ struct zpci_dev { char res_name[16]; bool mio_capable; - struct zpci_bar_struct bars[PCI_BAR_COUNT]; + struct zpci_bar_struct bars[PCI_STD_NUM_BARS]; u64 start_dma; /* Start of available DMA addresses */ u64 end_dma; /* End of available DMA addresses */ diff --git a/arch/s390/include/asm/pci_clp.h b/arch/s390/include/asm/pci_clp.h index 50359172cc48..bd2cb4ea7d93 100644 --- a/arch/s390/include/asm/pci_clp.h +++ b/arch/s390/include/asm/pci_clp.h @@ -77,7 +77,7 @@ struct mio_info { struct { u64 wb; u64 wt; - } addr[PCI_BAR_COUNT]; + } addr[PCI_STD_NUM_BARS]; u32 reserved[6]; } __packed; @@ -98,9 +98,9 @@ struct clp_rsp_query_pci { u16 util_str_avail : 1; /* utility string available? */ u16 pfgid : 8; /* pci function group id */ u32 fid; /* pci function id */ - u8 bar_size[PCI_BAR_COUNT]; + u8 bar_size[PCI_STD_NUM_BARS]; u16 pchid; - __le32 bar[PCI_BAR_COUNT]; + __le32 bar[PCI_STD_NUM_BARS]; u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ u32 : 16; u8 fmb_len; diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index b0e3b9a0e488..aca372c8e34f 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -43,7 +43,7 @@ static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES); static DEFINE_SPINLOCK(zpci_domain_lock); #define ZPCI_IOMAP_ENTRIES \ - min(((unsigned long) ZPCI_NR_DEVICES * PCI_BAR_COUNT / 2), \ + min(((unsigned long) ZPCI_NR_DEVICES * PCI_STD_NUM_BARS / 2), \ ZPCI_IOMAP_MAX_ENTRIES) static DEFINE_SPINLOCK(zpci_iomap_lock); @@ -294,7 +294,7 @@ static void __iomem *pci_iomap_range_mio(struct pci_dev *pdev, int bar, void __iomem *pci_iomap_range(struct pci_dev *pdev, int bar, unsigned long offset, unsigned long max) { - if (!pci_resource_len(pdev, bar) || bar >= PCI_BAR_COUNT) + if (bar >= PCI_STD_NUM_BARS || !pci_resource_len(pdev, bar)) return NULL; if (static_branch_likely(&have_mio)) @@ -324,7 +324,7 @@ static void __iomem *pci_iomap_wc_range_mio(struct pci_dev *pdev, int bar, void __iomem *pci_iomap_wc_range(struct pci_dev *pdev, int bar, unsigned long offset, unsigned long max) { - if (!pci_resource_len(pdev, bar) || bar >= PCI_BAR_COUNT) + if (bar >= PCI_STD_NUM_BARS || !pci_resource_len(pdev, bar)) return NULL; if (static_branch_likely(&have_mio)) @@ -416,7 +416,7 @@ static void zpci_map_resources(struct pci_dev *pdev) resource_size_t len; int i; - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { len = pci_resource_len(pdev, i); if (!len) continue; @@ -451,7 +451,7 @@ static void zpci_unmap_resources(struct pci_dev *pdev) if (zpci_use_mio(zdev)) return; - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { len = pci_resource_len(pdev, i); if (!len) continue; @@ -514,7 +514,7 @@ static int zpci_setup_bus_resources(struct zpci_dev *zdev, snprintf(zdev->res_name, sizeof(zdev->res_name), "PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR); - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (!zdev->bars[i].size) continue; entry = zpci_alloc_iomap(zdev); @@ -551,7 +551,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) { int i; - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (!zdev->bars[i].size || !zdev->bars[i].res) continue; @@ -573,7 +573,7 @@ int pcibios_add_device(struct pci_dev *pdev) pdev->dev.dma_ops = &s390_pci_dma_ops; zpci_map_resources(pdev); - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { res = &pdev->resource[i]; if (res->parent || !res->flags) continue; diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 9bdff4defef1..8b729b5f2972 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -145,7 +145,7 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev, { int i; - for (i = 0; i < PCI_BAR_COUNT; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { zdev->bars[i].val = le32_to_cpu(response->bar[i]); zdev->bars[i].size = response->bar_size[i]; } @@ -164,8 +164,8 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev, sizeof(zdev->util_str)); } zdev->mio_capable = response->mio_addr_avail; - for (i = 0; i < PCI_BAR_COUNT; i++) { - if (!(response->mio.valid & (1 << (PCI_BAR_COUNT - i - 1)))) + for (i = 0; i < PCI_STD_NUM_BARS; i++) { + if (!(response->mio.valid & (1 << (PCI_STD_NUM_BARS - i - 1)))) continue; zdev->bars[i].mio_wb = (void __iomem *) response->mio.addr[i].wb; From patchwork Mon Sep 16 20:41:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147763 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C624014ED for ; Mon, 16 Sep 2019 20:44:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADC7321670 for ; Mon, 16 Sep 2019 20:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403903AbfIPUoS (ORCPT ); Mon, 16 Sep 2019 16:44:18 -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-Google-Smtp-Source: APXvYqyJ3ewqCnuMqQSgNrhQ5ujo5Ot5mz2frJOPfWzvyP7uB9VEJUyuLp7vwR5tDGXsa+ET0xbVIg== 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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; From patchwork Mon Sep 16 20:41:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147761 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AF3014ED for ; Mon, 16 Sep 2019 20:44:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0356C214AF for ; Mon, 16 Sep 2019 20:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403919AbfIPUoU (ORCPT ); Mon, 16 Sep 2019 16:44:20 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40294 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403842AbfIPUoT (ORCPT ); Mon, 16 Sep 2019 16:44:19 -0400 Received: by mail-wm1-f65.google.com with SMTP id b24so687714wmj.5; Mon, 16 Sep 2019 13:44:16 -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=3sxSYLfbzulAgVeJ0Is1a2sfy/t0mpOhwffZAY40o0o=; b=eMKsVjJD86TT6IgqxLR6Yov40d+L5VLH7t4imYpR9nBnjVcAQE2fkID+DgR8n3eBn+ MT38tbOMS/7cXklWDqdBiVhqoWD17SWvXrDOVGlq4bznqNJJb5XeK8Eh46i2EEZIDsVG Rdo6+c/x56Gh5+TrvKWWlsFpoojiMn1b6Bxirymmw4SDW6Do3RliAJT7zyMgtQaAidja A3XM/KS2W1PLMrHTa76m8kRcVkocYrlK/TL+PFi2sTOTeej19VxM0HCuhrjl3A5eW4VX NnTXCUga7Jb93c/57Pp8YAd08yNWD/EZCDC6iYTycTnufCDZnAz1ToBPhmsZOnHZLtMC fCPQ== X-Gm-Message-State: APjAAAVq9h2QeiwQ3w82lSqQ5XYy8zjMLkjNEo9fK26AniC5A3MYC6Q/ qxZXHLgTZf5+rGvqx6mS/6w= X-Google-Smtp-Source: APXvYqz89ScpfpAp1SlFgiH/W3BfTQfscU2KeuZpz2OZGSFYe/PLKrNhNHnVVFUEs4equmEex79WOw== X-Received: by 2002:a1c:dd0a:: with SMTP id u10mr667819wmg.100.1568666656316; Mon, 16 Sep 2019 13:44:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:15 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-alpha@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner Subject: [PATCH v3 08/26] alpha/PCI: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:40 +0300 Message-Id: <20190916204158.6889-9-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Signed-off-by: Denis Efremov --- arch/alpha/kernel/pci-sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c index f94c732fedeb..0021580d79ad 100644 --- a/arch/alpha/kernel/pci-sysfs.c +++ b/arch/alpha/kernel/pci-sysfs.c @@ -71,10 +71,10 @@ static int pci_mmap_resource(struct kobject *kobj, struct pci_bus_region bar; int i; - for (i = 0; i < PCI_ROM_RESOURCE; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) if (res == &pdev->resource[i]) break; - if (i >= PCI_ROM_RESOURCE) + if (i >= PCI_STD_NUM_BARS) return -ENODEV; if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) @@ -115,7 +115,7 @@ void pci_remove_resource_files(struct pci_dev *pdev) { int i; - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; @@ -232,7 +232,7 @@ int pci_create_resource_files(struct pci_dev *pdev) int retval; /* Expose the PCI resources from this device as files */ - for (i = 0; i < PCI_ROM_RESOURCE; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { /* skip empty resources */ if (!pci_resource_len(pdev, i)) From patchwork Mon Sep 16 20:41:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147765 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A25A213BD for ; Mon, 16 Sep 2019 20:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A4A1216C8 for ; Mon, 16 Sep 2019 20:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391509AbfIPUoo (ORCPT ); Mon, 16 Sep 2019 16:44:44 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36942 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387513AbfIPUoo (ORCPT ); Mon, 16 Sep 2019 16:44:44 -0400 Received: by mail-wm1-f67.google.com with SMTP id r195so707315wme.2; Mon, 16 Sep 2019 13:44:41 -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=z7l3aUvXVj0B4HmmemvPXtwnQthJwDdKiNtC0WPyylI=; b=oHehi/5o+BNYiojA1ENYI+u+vp9T+Lgkqy3Be/I6t/Tjgi+v+UkbCjzDRZutcHXVwv /HtBZKhgsJrf/03M/hTnaa7pegqPXX6GbvrHInnUKo4cCf7C06Xtri3dwwMTv9rl59bF upXd0SczvWHwmEwKxCXNtEByPsc02QTURs7GJUA2KgxZ1Nm/0eaZs0Yc2ixNMarXlWhf EJ3wSW6S9VTEsQrkGB9sE8vMRsLcihYlLbZJrO5c+NgTeRWqpF+f1ad2n/Cqssyh6CqQ wHebEfvC5CATftzY68Zfq8BhmPRtbgtVBDYIyj60AU39cyWr7iGFEqTyWe3rIdqsh2xr VxfA== X-Gm-Message-State: APjAAAXeJPo88eYbvib/m3Ozp4fhxFlAzHKdURAKZYSmupHAkRCM0FHn V4D++mcTrMn6Ahi2TWVhlz8= X-Google-Smtp-Source: APXvYqwmIDihAakEBWNT+Q6Du50C/CVUM793sq+dvYqGdI/1XywI6PROEUB6R/C69wEz/+yKfv1AaA== X-Received: by 2002:a1c:9cd0:: with SMTP id f199mr646857wme.111.1568666681325; Mon, 16 Sep 2019 13:44:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:40 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-ia64@vger.kernel.org, Tony Luck , Fenghua Yu Subject: [PATCH v3 09/26] ia64: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:41 +0300 Message-Id: <20190916204158.6889-10-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Denis Efremov --- arch/ia64/sn/pci/pcibr/pcibr_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/sn/pci/pcibr/pcibr_dma.c b/arch/ia64/sn/pci/pcibr/pcibr_dma.c index 1e863b277ac9..ff981e415a28 100644 --- a/arch/ia64/sn/pci/pcibr/pcibr_dma.c +++ b/arch/ia64/sn/pci/pcibr/pcibr_dma.c @@ -295,14 +295,14 @@ void sn_dma_flush(u64 addr) /* find a matching BAR */ for (i = 0; i < DEV_PER_WIDGET; i++,p++) { common = p->common; - for (j = 0; j < PCI_ROM_RESOURCE; j++) { + for (j = 0; j < PCI_STD_NUM_BARS; j++) { if (common->sfdl_bar_list[j].start == 0) break; if (addr >= common->sfdl_bar_list[j].start && addr <= common->sfdl_bar_list[j].end) break; } - if (j < PCI_ROM_RESOURCE && common->sfdl_bar_list[j].start != 0) + if (j < PCI_STD_NUM_BARS && common->sfdl_bar_list[j].start != 0) break; } From patchwork Mon Sep 16 20:41:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147769 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6ED814ED for ; Mon, 16 Sep 2019 20:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF3B8214AF for ; Mon, 16 Sep 2019 20:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391527AbfIPUor (ORCPT ); Mon, 16 Sep 2019 16:44:47 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46801 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387513AbfIPUor (ORCPT ); Mon, 16 Sep 2019 16:44:47 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so777012wrv.13; Mon, 16 Sep 2019 13:44:46 -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=ASUn9OH0qpdm5tauYuwAj3Acnc10dNAyecbrZXIKD5k=; b=IOX9zDkbrJ+ugKjM6mr+410HW+5acMRt7yr8Hz3qpMJN5/ONBRaahTtzK4x5daSAS8 jOugofsotbg4JQghPUJWFMoSS2dWNR38/h5OHYaV1dnXU7k3NyCvRQ2XZdJfW3GRl/jr 2F0Vyb04Mp7Gi9uUISu8XUzpWzvj/Xo+VIm8m4uFpnr4cIcrqDkkLvDoqQchE8swNSk2 E0iEqwd6ci5q41F1tfFmVj6zalRV3Mx/oHXLFUMJa3UHWh8qL6xR/of+M4feOtzmQ+Ms vp2Cw17YvbKmHev+M9RdpC62uQbvroMxTAYvY4RKtYzN74It2DqgC+VzPC53sRjqpsd8 NGrQ== X-Gm-Message-State: APjAAAUc5etJPJ9hUj6vwbCyxeK5t0FNZtwezUAizCMRk1VOpycE3sMq Ir2hwL45diGjWKWURodmiStEEFo4AVw= X-Google-Smtp-Source: APXvYqxXKxOmo7vV3YO2KraQNHk6/pPJJCJXdwXVzZXSNDK+4XpNHBrvqCO9fO7iF2NaztvfDbTBIw== X-Received: by 2002:a5d:4590:: with SMTP id p16mr190844wrq.82.1568666686310; Mon, 16 Sep 2019 13:44:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:45 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-arm-kernel@lists.infradead.org, Alexandre Torgue , Giuseppe Cavallaro Subject: [PATCH v3 10/26] stmmac: pci: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:42 +0300 Message-Id: <20190916204158.6889-11-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". Cc: Alexandre Torgue Cc: Giuseppe Cavallaro Signed-off-by: Denis Efremov --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 86f9c07a38cf..cfe496cdd78b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -258,7 +258,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev, } /* Get the base address of device */ - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; ret = pcim_iomap_regions(pdev, BIT(i), pci_name(pdev)); @@ -296,7 +296,7 @@ static void stmmac_pci_remove(struct pci_dev *pdev) stmmac_dvr_remove(&pdev->dev); - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; pcim_iounmap_regions(pdev, BIT(i)); From patchwork Mon Sep 16 20:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147771 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 860E013BD for ; Mon, 16 Sep 2019 20:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64FD7206A4 for ; Mon, 16 Sep 2019 20:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387513AbfIPUoz (ORCPT ); Mon, 16 Sep 2019 16:44:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33212 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733036AbfIPUoz (ORCPT ); Mon, 16 Sep 2019 16:44:55 -0400 Received: by mail-wm1-f65.google.com with SMTP id r17so868397wme.0; Mon, 16 Sep 2019 13:44:54 -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=qzo9N5fUquDTsruLiXlDtb8ifZF0psYmg1XFgmwVlAE=; b=ofhXOsH398lqeN7n+lSzzu9Riov/tRnomBHh86IvYZakTibaIk8Fpe4GpTfVe4bUeY 7hcYEKJo6fDkzKf2QzZW+irI9fBta14cih0gTM5lamZKM5Qb0fFQowNTmZM0ly5ZbYoB tzKLlJ5V1bHgCkzjWPFw7kgZmBQGBO2b1XI2o8DaMDEz1wRitnV9AlgqLUTa90RhBUGU eL26hfXpVtkUuU6npfbgnQSRtBpfaHoIKQI7S6pBncHIueE1rFidrN84xFBoqXE8IJVt JGBTbS6cijyFVAlco7LIb6tOdDDtbNT4KJtesL2VlRiTf4VHu4XGAG/X+kz/TRxdl0FE b85Q== X-Gm-Message-State: APjAAAUukmtejsNnYlsfwQ1rqGMWEUGBK43hU2L97RLcCjPRADQ7ZtXg rpf8fcR7byhZjPLAKx5Ox84= X-Google-Smtp-Source: APXvYqyubIyIdrlstzf0Ad0JsGLLntibKR539vulOFUOeqSof1ITb8rIBEpmhXOL5xtxwKIsovzmNA== X-Received: by 2002:a7b:cbd0:: with SMTP id n16mr661540wmi.82.1568666693707; Mon, 16 Sep 2019 13:44:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:44:53 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , netdev@vger.kernel.org, Jose Abreu Subject: [PATCH v3 11/26] net: dwc-xlgmac: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:43 +0300 Message-Id: <20190916204158.6889-12-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". Cc: Jose Abreu Signed-off-by: Denis Efremov --- drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c b/drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c index 386bafe74c3f..fa8604d7b797 100644 --- a/drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c +++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c @@ -34,7 +34,7 @@ static int xlgmac_probe(struct pci_dev *pcidev, const struct pci_device_id *id) return ret; } - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pcidev, i) == 0) continue; ret = pcim_iomap_regions(pcidev, BIT(i), XLGMAC_DRV_NAME); From patchwork Mon Sep 16 20:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147773 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87C9614E5 for ; Mon, 16 Sep 2019 20:45:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7039520644 for ; Mon, 16 Sep 2019 20:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733036AbfIPUpa (ORCPT ); Mon, 16 Sep 2019 16:45:30 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39807 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbfIPUp3 (ORCPT ); Mon, 16 Sep 2019 16:45:29 -0400 Received: by mail-wm1-f68.google.com with SMTP id v17so693426wml.4; Mon, 16 Sep 2019 13:45:28 -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=QR/S6ZclFf3ctqEohNgiNTP20YUhWH32oSyd8G++lVQ=; b=f0YHPr6KR/5mTB4I6K26bDjwDoBUB5kWCbO2qAFmfBw4TEbjg/HCndFzzzBgVS0bya 3sfQwZ4KjngTafUtob1tIUuCuyM9RPlwZ8iVd37/ySr3CbIxsZZSJa4rRsKdF+Khtj0d NUKVZ1a3hjClT+bMxwsSdeUNGtuthNko8VcKU/LH0O8kzg6DVInUyPvgSMvNcFDQn0VW hniRQ/rzHQyl5Sff6HEliT0dvBSGJY5o4J+7xH6BwQzg/pP6vPMdPmB1k3f32jURYMOD zNW2tDWcq7wwaSyw3FDdfn01aMXhlbzs7WIFvsBvrDIMPSzTeV1sBqtGHuW1+RN+DoOy IMlQ== X-Gm-Message-State: APjAAAVGNBgxXmwKL/CRDnepNZ7PKO9Bv834SWadNhnBiGNk2bUbzOzp qjJK5NDNN3n5VuXNmnc/Wfc= X-Google-Smtp-Source: APXvYqztjSg5+p90FlyscHFtm0sWqlZ7NHCNyXeOHpO3+SNipAPorA1rmqYMQHfsoiE2lPw4x64s0Q== X-Received: by 2002:a1c:bcd6:: with SMTP id m205mr627239wmf.129.1568666727659; Mon, 16 Sep 2019 13:45:27 -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.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:45:27 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , netdev@vger.kernel.org, Jeff Kirsher , "David S. Miller" Subject: [PATCH v3 12/26] ixgb: use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:44 +0300 Message-Id: <20190916204158.6889-13-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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. Cc: Jeff Kirsher Cc: "David S. Miller" Signed-off-by: Denis Efremov --- drivers/net/ethernet/intel/ixgb/ixgb.h | 1 - drivers/net/ethernet/intel/ixgb/ixgb_main.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgb/ixgb.h b/drivers/net/ethernet/intel/ixgb/ixgb.h index e85271b68410..681d44cc9784 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb.h +++ b/drivers/net/ethernet/intel/ixgb/ixgb.h @@ -42,7 +42,6 @@ #define BAR_0 0 #define BAR_1 1 -#define BAR_5 5 struct ixgb_adapter; #include "ixgb_hw.h" diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index e5ac2d3fd816..c5bba18eb32a 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -412,7 +412,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_ioremap; } - for (i = BAR_1; i <= BAR_5; i++) { + for (i = BAR_1; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { From patchwork Mon Sep 16 20:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147775 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A938414E5 for ; Mon, 16 Sep 2019 20:45:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9162E20830 for ; Mon, 16 Sep 2019 20:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391559AbfIPUpi (ORCPT ); Mon, 16 Sep 2019 16:45:38 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34375 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbfIPUph (ORCPT ); Mon, 16 Sep 2019 16:45:37 -0400 Received: by mail-wr1-f68.google.com with SMTP id a11so871077wrx.1; Mon, 16 Sep 2019 13:45:35 -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=M1ZS90764/FVzY30XHh7UWixn+HhsaFXDfA2e3hQE2w=; b=mZRpJpKYdjD/+XXl0WODP6vSrqivr7IGe5tjubBAsG1BasDHAuJ6M6I/+yXmew5kIb pZgAcZdYKkKDla0uidxcTUZst3shFFaE+Pvj25LBDGrNf/Z+vJ8Cx7jD7kjXBuDpecfo g4WnupsZlAjepeN61RxU9GMdpBi7iH2il4eeFJe3KrEtCrs0/Ftgn1PxC30xW1x38aZG jPStpRaiWFks75X6gWYY1OH7FPRZPGTvqxK0DAPVqAhKn6rtwo3Y5h6leqWPSbZLuzII srs6Dgh2h95qTCK6mKi4v7bYa3nd0ZV1F2QHA0mEoC4GMA4K29BwJs1T78qPWudR/F4C ohgg== X-Gm-Message-State: APjAAAVkAfWczaokSO3BRJgS0EtQybNO/gy8XR50o5PkuOYFOKPm9zg0 2ct0wPpU/5qsHiY6RglU5Zc= X-Google-Smtp-Source: APXvYqwDWU5ArjS7gzWl4fYqQGrhHTqL0s1rQuZlWAFSAZTLLXsZad+mPx9KuMQHVFx2pUboEnyPiw== X-Received: by 2002:a5d:61c4:: with SMTP id q4mr159268wrv.327.1568666734658; Mon, 16 Sep 2019 13:45:34 -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.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:45:34 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , netdev@vger.kernel.org, Jeff Kirsher , "David S. Miller" Subject: [PATCH v3 13/26] e1000: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:45 +0300 Message-Id: <20190916204158.6889-14-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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. Cc: Jeff Kirsher Cc: "David S. Miller" Signed-off-by: Denis Efremov --- drivers/net/ethernet/intel/e1000/e1000.h | 1 - drivers/net/ethernet/intel/e1000/e1000_main.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h index c40729b2c184..7fad2f24dcad 100644 --- a/drivers/net/ethernet/intel/e1000/e1000.h +++ b/drivers/net/ethernet/intel/e1000/e1000.h @@ -45,7 +45,6 @@ #define BAR_0 0 #define BAR_1 1 -#define BAR_5 5 #define INTEL_E1000_ETHERNET_DEVICE(device_id) {\ PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index f703fa58458e..db4fd82036af 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -977,7 +977,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_ioremap; if (adapter->need_ioport) { - for (i = BAR_1; i <= BAR_5; i++) { + for (i = BAR_1; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { From patchwork Mon Sep 16 20:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147777 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1B0914ED for ; Mon, 16 Sep 2019 20:45:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C95E020644 for ; Mon, 16 Sep 2019 20:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391595AbfIPUpl (ORCPT ); Mon, 16 Sep 2019 16:45:41 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39853 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbfIPUpk (ORCPT ); Mon, 16 Sep 2019 16:45:40 -0400 Received: by mail-wr1-f67.google.com with SMTP id r3so831768wrj.6; Mon, 16 Sep 2019 13:45:39 -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=6eXx97jIUvnWKUhsHS/jDfcPmaEhHScsepaLww/BGjQ=; b=se4ZXQsR3iyN4fqmN5C+nAf65xEPcucEC84URvhLQnNfDjay1x66bkSf+QDBdY0Yl5 8kkezgv83ea6FNzkKNOSt2lrbmkvWKhP1htk4qj1Ir6KcGXHwydMAWGqH4nxnwM2Nkmj yqFtpeLOUzOztsrY7q2pRK6FOx8SEQlMjc3rDm23Phs3poUMfCgPY/OR0R9hjbRxv337 gP/sVhddCFLUJpTSZGOp+2ppyEGg/WfXf4xN4ElTjN5o04yWOeWuCeqMQU3arI6d50/p 3m3mH0p8rdEaPFr91NsHcTZZRUet8sXc0VrrQ7wnqMHWWNOG+s2vtuGRo27mcQEXIJUW fGNQ== X-Gm-Message-State: APjAAAWvv3C6hu1Nb2M7QgJWZ90mOZaRtgpp1S/mXFnKDLmRR9alPaOx MraoszOiFIS2YJy1xj5HqI21oxYqrFc= X-Google-Smtp-Source: APXvYqyHM8UA9SDJz1d8txwgNTURDLDNvolNfIMcs9JKwmOiilqCjpc62ifIaPkDslH6MdK8gAZZ4Q== X-Received: by 2002:a5d:5692:: with SMTP id f18mr198870wrv.68.1568666739007; Mon, 16 Sep 2019 13:45:39 -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.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:45:38 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , Matt Porter , Alexandre Bounine Subject: [PATCH v3 14/26] rapidio/tsi721: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:46 +0300 Message-Id: <20190916204158.6889-15-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". Cc: Matt Porter Cc: Alexandre Bounine Signed-off-by: Denis Efremov --- drivers/rapidio/devices/tsi721.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c index 125a173bed45..4dd31dd9feea 100644 --- a/drivers/rapidio/devices/tsi721.c +++ b/drivers/rapidio/devices/tsi721.c @@ -2755,7 +2755,7 @@ static int tsi721_probe(struct pci_dev *pdev, { int i; - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { tsi_debug(INIT, &pdev->dev, "res%d %pR", i, &pdev->resource[i]); } From patchwork Mon Sep 16 20:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147801 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D85E14ED for ; Mon, 16 Sep 2019 20:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55925206A4 for ; Mon, 16 Sep 2019 20:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733197AbfIPUrQ (ORCPT ); Mon, 16 Sep 2019 16:47:16 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35760 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrQ (ORCPT ); Mon, 16 Sep 2019 16:47:16 -0400 Received: by mail-wm1-f66.google.com with SMTP id y21so724089wmi.0; Mon, 16 Sep 2019 13:47:15 -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=ClDwwNU7E7yVLshOYSMVtt4b9UbBrgClZoV7wecu9U4=; b=kx1FcIuxqvx/TvGD90QWt4xhIZr0MLjjtDVYiHMWkygeBFSujBP4FQDu5Vo+F6vaY3 stlQ4K7oUUXrBK1zm2R70twTq1Hg+exGa2hVWpJkUH7Ojpp3b+L0NikXbEDfiXIe4L82 ah+BTen1SSD1o/HY5A9y6U1YbsWXHvFyO8ZF2LU6eZF8Dv/kKaR1oXZsgoYx3wx8eKHU CjxCH1bIHYi/hqrOaQr6E9F6SYwowTpcikuylyBSeLqD0Xt7QYAqaOICjapY2tMHi49r TDPTTmP0uSBok/5Ch+JlwIGj11b/J8AAHzMrwCtK5cuFcsKU0S50Zt+VBxKc1oJ+tBCe WBIg== X-Gm-Message-State: APjAAAUN7xBbYgORE2bYQUB3TnE4xxj99DMOg7NQp1t4BvYCr4TLexQw ZLRzKSujOf2B4R5gd0kqz88= X-Google-Smtp-Source: APXvYqzA8iGacIv6b2eMRXNGIb5zr8TCz3Zb1d24cr0J6lDgd8GrnibalyRautcKXUroaMlIrfhYbw== X-Received: by 2002:a1c:7319:: with SMTP id d25mr675553wmb.56.1568666834587; Mon, 16 Sep 2019 13:47: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.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:14 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Peter Jones Subject: [PATCH v3 15/26] efifb: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:47 +0300 Message-Id: <20190916204158.6889-16-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". Acked-by: Bartlomiej Zolnierkiewicz Cc: Peter Jones Signed-off-by: Denis Efremov --- drivers/video/fbdev/efifb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 04a22663b4fb..6c72b825e92a 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -668,7 +668,7 @@ static void efifb_fixup_resources(struct pci_dev *dev) if (!base) return; - for (i = 0; i <= PCI_STD_RESOURCE_END; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct resource *res = &dev->resource[i]; if (!(res->flags & IORESOURCE_MEM)) From patchwork Mon Sep 16 20:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147807 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10CD61747 for ; Mon, 16 Sep 2019 20:47:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED9F4206A4 for ; Mon, 16 Sep 2019 20:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388124AbfIPUrW (ORCPT ); Mon, 16 Sep 2019 16:47:22 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38069 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrW (ORCPT ); Mon, 16 Sep 2019 16:47:22 -0400 Received: by mail-wm1-f67.google.com with SMTP id o184so706097wme.3; Mon, 16 Sep 2019 13:47:20 -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=ujovi4XPDNySnmAMKOgDa4VaedmyqoxIIAtYaqvsCwo=; b=QfDhwKjIJ0ubzz44BRt0mpxEHpE18jjp1L1Iduzq47jtT7F1GeWvFGKK3uVdmu6tqI kyVwMoo77npQvUN4+kqsW68CX3UgHn52lXubKMoAFy2NWdreV5ZrDwl6UlLRME8j+8zH IjLJgXhiq4fgFfGvHnQRdjJeT3dxhqpuN8YWqLZNOHerdEaASkuL6k2YFRwYWVztdZGK TwuVHQ3khtR4adqYsVN5gaVuCf1yt0ovuOq6otyzpfQZ4z8d5di10UQSz4AXJ3uB17zO AfFVBJ0wBieeMQ0mPV1jlT/NnBfO4B3TlCoiNCiQtPM7wNZmBx3oF46nztgQxd7AkKEo drOg== X-Gm-Message-State: APjAAAXe5Z68LHg/XtxgJJxsQ2vChYJurLivdBILMQaO/3K9g3riOYCN 3dnNuJ5VL0dsLlN1ya3IL70TgUDUYSE= X-Google-Smtp-Source: APXvYqwJN5xzlDI6G/MI49jkTwJJQQnvs9yDf29e2hrZ3u/WBbjKYtYB4auYSROBjzRE2CuBPOpyEA== X-Received: by 2002:a1c:9cd0:: with SMTP id f199mr652570wme.111.1568666839843; Mon, 16 Sep 2019 13:47:19 -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.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:19 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Daniel Vetter Subject: [PATCH v3 16/26] fbmem: use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:48 +0300 Message-Id: <20190916204158.6889-17-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Bartlomiej Zolnierkiewicz Cc: Daniel Vetter Signed-off-by: Denis Efremov --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 64dd732021d8..485e798cd404 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1784,7 +1784,7 @@ int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const int err, idx, bar; bool res_id_found = false; - for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) { + for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) continue; idx++; @@ -1794,7 +1794,7 @@ int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const if (!ap) return -ENOMEM; - for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) { + for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) continue; ap->ranges[idx].base = pci_resource_start(pdev, bar); From patchwork Mon Sep 16 20:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147809 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3643414E5 for ; Mon, 16 Sep 2019 20:47:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 147F020644 for ; Mon, 16 Sep 2019 20:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728320AbfIPUrb (ORCPT ); Mon, 16 Sep 2019 16:47:31 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52034 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrb (ORCPT ); Mon, 16 Sep 2019 16:47:31 -0400 Received: by mail-wm1-f65.google.com with SMTP id 7so797937wme.1; Mon, 16 Sep 2019 13:47:28 -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=QLQPAYHUACHzoMzXgGl4aMEibp9KP46d8BzQG7n7Uds=; b=hm760oHm3uMSkpxZuRLuBvLrNOeyALAfldCHV1fv5zO0kMAXr9Vg6hYrsMdJdxoRRl iP6pAOxGvvtlypfAf2m7olv+nkopteVT9K+4DmxuEk9fiqTvK3nxkyJUgDkftAhnsp+7 MTdVWhQDxmHCErYb4N8ZLbjNgLmUMnFb4rt64Z91GLefd9s29iKGvWOzuJHVv44bHpdX GxD+ae5EtGMO2r3hDnkwAd1oFNhWqPBRR6tDgtxGT1tdXJFTmyC9WzFVFiE+fpxvIb33 GkXCRUwxzk2+GGBSw8/O3BwWqTFYB0r5Y0B1yQEo8jrk3kJPt6VzHyCjGiD+po34nnbM UJrA== X-Gm-Message-State: APjAAAWxnD8kmzyWvIZZ/C27SIeqs74z95hA9Y6o8Gai+YdUJxuqIikx ukCGvDPrzT03bbDL++sAUaw= X-Google-Smtp-Source: APXvYqxISkd0F2RDS0tk8mctmfGj06rkked0k46A5N+m1h5H/Qt5p0hKECOmJeL+5l43LAR/maBo9Q== X-Received: by 2002:a1c:dd0a:: with SMTP id u10mr674534wmg.100.1568666847741; Mon, 16 Sep 2019 13:47:27 -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.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:27 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , kvm@vger.kernel.org, Cornelia Huck , Alex Williamson Subject: [PATCH v3 17/26] vfio_pci: Loop using PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:49 +0300 Message-Id: <20190916204158.6889-18-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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". Cc: Cornelia Huck Cc: Alex Williamson Signed-off-by: Denis Efremov --- drivers/vfio/pci/vfio_pci.c | 11 ++++++---- drivers/vfio/pci/vfio_pci_config.c | 32 +++++++++++++++-------------- drivers/vfio/pci/vfio_pci_private.h | 4 ++-- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 703948c9fbe1..cb7d220d3246 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -110,13 +110,15 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pdev) static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) { struct resource *res; - int bar; + int i; struct vfio_pci_dummy_resource *dummy_res; INIT_LIST_HEAD(&vdev->dummy_resources_list); - for (bar = PCI_STD_RESOURCES; bar <= PCI_STD_RESOURCE_END; bar++) { - res = vdev->pdev->resource + bar; + for (i = 0; i < PCI_STD_NUM_BARS; i++) { + int bar = i + PCI_STD_RESOURCES; + + res = &vdev->pdev->resource[bar]; if (!IS_ENABLED(CONFIG_VFIO_PCI_MMAP)) goto no_mmap; @@ -399,7 +401,8 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev) vfio_config_free(vdev); - for (bar = PCI_STD_RESOURCES; bar <= PCI_STD_RESOURCE_END; bar++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { + bar = i + PCI_STD_RESOURCES; if (!vdev->barmap[bar]) continue; pci_iounmap(pdev, vdev->barmap[bar]); diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index f0891bd8444c..90c0b80f8acf 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -450,30 +450,32 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev) { struct pci_dev *pdev = vdev->pdev; int i; - __le32 *bar; + __le32 *vbar; u64 mask; - bar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0]; + vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0]; - for (i = PCI_STD_RESOURCES; i <= PCI_STD_RESOURCE_END; i++, bar++) { - if (!pci_resource_start(pdev, i)) { - *bar = 0; /* Unmapped by host = unimplemented to user */ + for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) { + int bar = i + PCI_STD_RESOURCES; + + if (!pci_resource_start(pdev, bar)) { + *vbar = 0; /* Unmapped by host = unimplemented to user */ continue; } - mask = ~(pci_resource_len(pdev, i) - 1); + mask = ~(pci_resource_len(pdev, bar) - 1); - *bar &= cpu_to_le32((u32)mask); - *bar |= vfio_generate_bar_flags(pdev, i); + *vbar &= cpu_to_le32((u32)mask); + *vbar |= vfio_generate_bar_flags(pdev, bar); - if (*bar & cpu_to_le32(PCI_BASE_ADDRESS_MEM_TYPE_64)) { - bar++; - *bar &= cpu_to_le32((u32)(mask >> 32)); + if (*vbar & cpu_to_le32(PCI_BASE_ADDRESS_MEM_TYPE_64)) { + vbar++; + *vbar &= cpu_to_le32((u32)(mask >> 32)); i++; } } - bar = (__le32 *)&vdev->vconfig[PCI_ROM_ADDRESS]; + vbar = (__le32 *)&vdev->vconfig[PCI_ROM_ADDRESS]; /* * NB. REGION_INFO will have reported zero size if we weren't able @@ -483,14 +485,14 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev) if (pci_resource_start(pdev, PCI_ROM_RESOURCE)) { mask = ~(pci_resource_len(pdev, PCI_ROM_RESOURCE) - 1); mask |= PCI_ROM_ADDRESS_ENABLE; - *bar &= cpu_to_le32((u32)mask); + *vbar &= cpu_to_le32((u32)mask); } else if (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) { mask = ~(0x20000 - 1); mask |= PCI_ROM_ADDRESS_ENABLE; - *bar &= cpu_to_le32((u32)mask); + *vbar &= cpu_to_le32((u32)mask); } else - *bar = 0; + *vbar = 0; vdev->bardirty = false; } diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h index ee6ee91718a4..8a2c7607d513 100644 --- a/drivers/vfio/pci/vfio_pci_private.h +++ b/drivers/vfio/pci/vfio_pci_private.h @@ -86,8 +86,8 @@ struct vfio_pci_reflck { struct vfio_pci_device { struct pci_dev *pdev; - void __iomem *barmap[PCI_STD_RESOURCE_END + 1]; - bool bar_mmap_supported[PCI_STD_RESOURCE_END + 1]; + void __iomem *barmap[PCI_STD_NUM_BARS]; + bool bar_mmap_supported[PCI_STD_NUM_BARS]; u8 *pci_config_map; u8 *vconfig; struct perm_bits *msi_perm; From patchwork Mon Sep 16 20:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147835 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D7DC14ED for ; Mon, 16 Sep 2019 20:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45349206A4 for ; Mon, 16 Sep 2019 20:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391441AbfIPUrd (ORCPT ); Mon, 16 Sep 2019 16:47:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39044 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrd (ORCPT ); Mon, 16 Sep 2019 16:47:33 -0400 Received: by mail-wr1-f66.google.com with SMTP id r3so836298wrj.6; Mon, 16 Sep 2019 13:47:31 -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=epEuwg1xdHKPnwPm1RSe5GQMDsYIT9iwwxBPtEKOzsY=; b=VH/BPBRoJc2UtuPBlt6h893+Rb9g0zeYgYN+IGMRAoi1+e2d3EHKAr6Fgwk6fPENN6 +JXy+fEBrgtbId09z3/S3BKJQlr9XkHysn+cSrq6PhRt+U4M1Zc35IAHaw3vUxEBBubV 42C4P60Q1W2jLtiP7sr5ehVCMMbsbRqk4z10rpMJLNEgAmHjuzlEGvKxsFhx9SnTCNUV 3WSfIpOrOWzpGv/VJTKLZOCaaK4PnPtCNHQCc2Q9lgD0lSXq12TVRTBbr4VpDTWZ7Pcq 1G8ETfuPaAguNOwm8rGNfH10nJ6B1SgxyIAFevQsQ1zgaaVYZZ/0L7z7tOyuvSDC80hr EN7g== X-Gm-Message-State: APjAAAXK8slm0U3Uqb+VDWcqAMxFffDwPR+YAsnYrM6CkeqTRK+35g6s KU2jr7jm3dwEEhuOFTEMHZg= X-Google-Smtp-Source: APXvYqzUQ8ilo7HfmXcpWyMR/2qbH1CpYDfMJItElWXHm2aMMFZcq3bt10sbQbWR1+fPh2AtB2M7Mw== X-Received: by 2002:adf:ab0b:: with SMTP id q11mr212288wrc.336.1568666851199; Mon, 16 Sep 2019 13:47:31 -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.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:30 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-scsi@vger.kernel.org, Jack Wang , "James E.J. Bottomley" Subject: [PATCH v3 18/26] scsi: pm80xx: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:50 +0300 Message-Id: <20190916204158.6889-19-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Replace the magic constant (6) with define PCI_STD_NUM_BARS representing the number of PCI BARs. Cc: Jack Wang Cc: "James E.J. Bottomley" Signed-off-by: Denis Efremov Acked-by: Jack Wang Acked-by: Martin K. Petersen --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm8001_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 68a8217032d0..1a3661d6be06 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1186,7 +1186,7 @@ static void pm8001_hw_chip_rst(struct pm8001_hba_info *pm8001_ha) void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha) { s8 bar, logical = 0; - for (bar = 0; bar < 6; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { /* ** logical BARs for SPC: ** bar 0 and 1 - logical BAR0 diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 3374f553c617..aca913490eb5 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -401,7 +401,7 @@ static int pm8001_ioremap(struct pm8001_hba_info *pm8001_ha) pdev = pm8001_ha->pdev; /* map pci mem (PMC pci base 0-3)*/ - for (bar = 0; bar < 6; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { /* ** logical BARs for SPC: ** bar 0 and 1 - logical BAR0 From patchwork Mon Sep 16 20:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147833 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A92514E5 for ; Mon, 16 Sep 2019 20:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0902B2171F for ; Mon, 16 Sep 2019 20:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391574AbfIPUrg (ORCPT ); Mon, 16 Sep 2019 16:47:36 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39050 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391566AbfIPUrf (ORCPT ); Mon, 16 Sep 2019 16:47:35 -0400 Received: by mail-wr1-f68.google.com with SMTP id r3so836397wrj.6; Mon, 16 Sep 2019 13:47:34 -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=2FqysY5HATBDrBuyFDyYiBCyyYkjbnS9XQbtyyTHOy0=; b=GhMsmFP1zvXpfnfVTo1EVsAoGnZ2fuNtYU2CusLxWV/znhtGb0RGeJBLQUyjD4i2TF BmgUyCQj+6La8dwUAMQ6pULn6YG5ZLAuD8ZIXokTQ0BGRWxsPJBh61JsMznzwZPwnXP9 2jsHkumrBxsk8PkN81ZuGOxv39FuRSOS6Qgv9f/SZsjaEAbFDjP/v9vSJ0dYQZkVc42j FY6Ew+jkMy/McFio618C6amtQ1hcvSuAD9+U9PR9rCCev3L8wHerF39frCg2ig9fiQo4 7nmUxfassNcaT8uoTzpxfHHF3FHMpq/Pozys1H6ojr93kHuGvWAbeF47hb/l2Z94dXg7 VGBQ== X-Gm-Message-State: APjAAAXkDxbAwnAUNkF9y1vb4uWVIE7pAauwk81xTsJK1wDLcyVPGssY zoaJ1AViip+ESEhxibh7HVNcpIPW0zM= X-Google-Smtp-Source: APXvYqyImLLCgKryGD8YrkgXaU55B5YLepDP0MFlB8OxuTaSZRBDTlao8EoEJYIvZczQZHXYodK1qg== X-Received: by 2002:a5d:63c6:: with SMTP id c6mr204595wrw.117.1568666853795; Mon, 16 Sep 2019 13:47:33 -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.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:33 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-ide@vger.kernel.org, Jens Axboe Subject: [PATCH v3 19/26] ata: sata_nv: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:51 +0300 Message-Id: <20190916204158.6889-20-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Replace the magic constant (6) with define PCI_STD_NUM_BARS representing the number of PCI BARs. Cc: Jens Axboe Signed-off-by: Denis Efremov --- drivers/ata/sata_nv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index b44b4b64354c..31a32a4bb05b 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c @@ -2329,7 +2329,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) // Make sure this is a SATA controller by counting the number of bars // (NVIDIA SATA controllers will always have six bars). Otherwise, // it's an IDE controller and we ignore it. - for (bar = 0; bar < 6; bar++) + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) if (pci_resource_start(pdev, bar) == 0) return -ENODEV; From patchwork Mon Sep 16 20:41:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147813 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E722B14ED for ; Mon, 16 Sep 2019 20:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5D9020644 for ; Mon, 16 Sep 2019 20:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391620AbfIPUrh (ORCPT ); Mon, 16 Sep 2019 16:47:37 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33425 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrh (ORCPT ); Mon, 16 Sep 2019 16:47:37 -0400 Received: by mail-wm1-f68.google.com with SMTP id r17so872777wme.0; Mon, 16 Sep 2019 13:47:36 -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=hIaCxdmc4Mv8gjZ6OZgOWrffbO/JWGkLQPEVsPVt/ms=; b=FIpGy+/wT7Ofs4xwqI15sZ4utyBbsg7vrYiNZf4X/kJEKrhhHZ80A3VnEuLzUHiwcR r8VhIxMpU0cq8kMDNkqQh9q2vaZb5r7Is0SOWw7/PCgp03ztTzWlg9MQNcH1uZLP2IqA CJCWKDe4raZN1E1IjuBFM2MXUVmq0va3nR0FjTSepUKh+l/g3kIOusllXCGCOnPMerjs D8CUW05kY3v5m/taqkpgNrtGPyTmavIp/gueEaFuR3qNm8ymzh5pUzGLdIjLl3B2Mo2j SNG0oVfQgFK6Rm8crEzmPLMQ5eF2Uzcankv4nAWG1pRz9k/fepvigOvsuf+tlWQw6SLz 3Esg== X-Gm-Message-State: APjAAAWQL3SlgrGiyKRWddHEoIL8MlV0bA8E9qHn0CrrbWCn2yay7qbk Nb/PPXr34p+E4l+TChZU2PU= X-Google-Smtp-Source: APXvYqxV54TN6lC5/Jcuj+mDUpfWm3xDMt+2fNrtKXU0IdKBO73RRVso0NF9z88qEsbkVDCd7KhnGw== X-Received: by 2002:a7b:cc0a:: with SMTP id f10mr778750wmh.6.1568666855820; Mon, 16 Sep 2019 13:47:35 -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.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:35 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , devel@driverdev.osuosl.org, Rob Springer , Todd Poynor , Ben Chan Subject: [PATCH v3 20/26] staging: gasket: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:52 +0300 Message-Id: <20190916204158.6889-21-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove local definition GASKET_NUM_BARS for the number of PCI BARs and use global one PCI_STD_NUM_BARS instead. Cc: Rob Springer Cc: Todd Poynor Cc: Ben Chan Signed-off-by: Denis Efremov --- drivers/staging/gasket/gasket_constants.h | 3 --- drivers/staging/gasket/gasket_core.c | 12 ++++++------ drivers/staging/gasket/gasket_core.h | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h index 50d87c7b178c..9ea9c8833f27 100644 --- a/drivers/staging/gasket/gasket_constants.h +++ b/drivers/staging/gasket/gasket_constants.h @@ -13,9 +13,6 @@ /* The maximum devices per each type. */ #define GASKET_DEV_MAX 256 -/* The number of supported (and possible) PCI BARs. */ -#define GASKET_NUM_BARS 6 - /* The number of supported Gasket page tables per device. */ #define GASKET_MAX_NUM_PAGE_TABLES 1 diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 13179f063a61..cd8be80d2076 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -371,7 +371,7 @@ static int gasket_setup_pci(struct pci_dev *pci_dev, { int i, mapped_bars, ret; - for (i = 0; i < GASKET_NUM_BARS; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { ret = gasket_map_pci_bar(gasket_dev, i); if (ret) { mapped_bars = i; @@ -393,7 +393,7 @@ static void gasket_cleanup_pci(struct gasket_dev *gasket_dev) { int i; - for (i = 0; i < GASKET_NUM_BARS; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) gasket_unmap_pci_bar(gasket_dev, i); } @@ -493,7 +493,7 @@ static ssize_t gasket_sysfs_data_show(struct device *device, (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type; switch (sysfs_type) { case ATTR_BAR_OFFSETS: - for (i = 0; i < GASKET_NUM_BARS; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { bar_desc = &driver_desc->bar_descriptions[i]; if (bar_desc->size == 0) continue; @@ -505,7 +505,7 @@ static ssize_t gasket_sysfs_data_show(struct device *device, } break; case ATTR_BAR_SIZES: - for (i = 0; i < GASKET_NUM_BARS; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { bar_desc = &driver_desc->bar_descriptions[i]; if (bar_desc->size == 0) continue; @@ -556,7 +556,7 @@ static ssize_t gasket_sysfs_data_show(struct device *device, ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count); break; case ATTR_USER_MEM_RANGES: - for (i = 0; i < GASKET_NUM_BARS; ++i) { + for (i = 0; i < PCI_STD_NUM_BARS; ++i) { current_written = gasket_write_mappable_regions(buf, driver_desc, i); @@ -736,7 +736,7 @@ static int gasket_get_bar_index(const struct gasket_dev *gasket_dev, const struct gasket_driver_desc *driver_desc; driver_desc = gasket_dev->internal_desc->driver_desc; - for (i = 0; i < GASKET_NUM_BARS; ++i) { + for (i = 0; i < PCI_STD_NUM_BARS; ++i) { struct gasket_bar_desc bar_desc = driver_desc->bar_descriptions[i]; diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index be44ac1e3118..c417acadb0d5 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -268,7 +268,7 @@ struct gasket_dev { char kobj_name[GASKET_NAME_MAX]; /* Virtual address of mapped BAR memory range. */ - struct gasket_bar_data bar_data[GASKET_NUM_BARS]; + struct gasket_bar_data bar_data[PCI_STD_NUM_BARS]; /* Coherent buffer. */ struct gasket_coherent_buffer coherent_buffer; @@ -369,7 +369,7 @@ struct gasket_driver_desc { /* Set of 6 bar descriptions that describe all PCIe bars. * Note that BUS/AXI devices (i.e. non PCI devices) use those. */ - struct gasket_bar_desc bar_descriptions[GASKET_NUM_BARS]; + struct gasket_bar_desc bar_descriptions[PCI_STD_NUM_BARS]; /* * Coherent buffer description. From patchwork Mon Sep 16 20:41:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147831 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B0B514E5 for ; Mon, 16 Sep 2019 20:48:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53B4E21852 for ; Mon, 16 Sep 2019 20:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391635AbfIPUrl (ORCPT ); Mon, 16 Sep 2019 16:47:41 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55692 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391630AbfIPUrk (ORCPT ); Mon, 16 Sep 2019 16:47:40 -0400 Received: by mail-wm1-f66.google.com with SMTP id g207so772961wmg.5; Mon, 16 Sep 2019 13:47:38 -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=rTWOX45cY57shcaylIoJs6ddXiu3evrGLFdFM3nnDoA=; b=ToRG7sGoLnEmzb7Y7+fzQ+X8fc0PN7PNw/v90XdWNeK1WBkEKl6r+bM6vB4mO+FCSt tlHsQNcftXrLGT7EeKw0kbmK1Uvn5G0W/iY+dkiJlsBTzaEnM1gVubxhZ6PEBF1exsp9 +8fRG5273rpVgHSBq8aQmzNU/16wGbl92gKct3JCBZMCN2uKbRfUM7XujlczCnkMzgZG oC8QOGk35nI4Uue4PaW9vDVDKnYkdUu6Q9vPu/WzCnTgTmDxg15ultbi/SmNWxrTZ30G liDO3o3AtcuffN0bi74PVQ97cZJEWOQAJdyLu/LpfOq43evD1IpQukOO1E3ARTw9qRk3 vGTQ== X-Gm-Message-State: APjAAAVlNKMZuGYKSzjw7KX81z+pxbICr7CwXD5Tj8ErsuKkIVNxdJ8G gbr9IHCT0oQKQxoEUDoRdCQ= X-Google-Smtp-Source: APXvYqx78NBHu5O0eYvC6JJ4sxSzd+aniNIZ9PxAMOMGGSLl159m95qtqj/2EsOQedkY7MpggXDTFQ== X-Received: by 2002:a1c:f917:: with SMTP id x23mr694988wmh.101.1568666858204; Mon, 16 Sep 2019 13:47:38 -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.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:37 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 21/26] serial: 8250_pci: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:53 +0300 Message-Id: <20190916204158.6889-22-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Remove local definition PCI_NUM_BAR_RESOURCES for the number of PCI BARs and use global one PCI_STD_NUM_BARS instead. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Signed-off-by: Denis Efremov --- drivers/tty/serial/8250/8250_pci.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 7f740b37700b..e557605ec75f 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -43,8 +43,6 @@ struct pci_serial_quirk { void (*exit)(struct pci_dev *dev); }; -#define PCI_NUM_BAR_RESOURCES 6 - struct serial_private { struct pci_dev *dev; unsigned int nr; @@ -74,7 +72,7 @@ setup_port(struct serial_private *priv, struct uart_8250_port *port, { struct pci_dev *dev = priv->dev; - if (bar >= PCI_NUM_BAR_RESOURCES) + if (bar >= PCI_STD_NUM_BARS) return -EINVAL; if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { @@ -3583,7 +3581,7 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) return -ENODEV; num_iomem = num_port = 0; - for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_flags(dev, i) & IORESOURCE_IO) { num_port++; if (first_port == -1) @@ -3611,7 +3609,7 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) */ first_port = -1; num_port = 0; - for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { + for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_flags(dev, i) & IORESOURCE_IO && pci_resource_len(dev, i) == 8 && (first_port == -1 || (first_port + num_port) == i)) { From patchwork Mon Sep 16 20:41:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147829 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2559214E5 for ; Mon, 16 Sep 2019 20:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04640214AF for ; Mon, 16 Sep 2019 20:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391649AbfIPUrn (ORCPT ); Mon, 16 Sep 2019 16:47:43 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36811 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfIPUrm (ORCPT ); Mon, 16 Sep 2019 16:47:42 -0400 Received: by mail-wm1-f67.google.com with SMTP id t3so716328wmj.1; Mon, 16 Sep 2019 13:47:41 -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=IOS2e0UepoELcBHR5ni67YDdvRavbzFfhcVGtDlKQTM=; b=XuITJ9/tp8KJKAOzlxh+TZajIZPbu3WOS+0GYuDCdB1P6CCJwR427RVA3O7p30prmn vfSAg7YXYnqaTnFS9wx3Rbybi4a7eLo7sXrxNwCS3JBzfq0nnCxZwtHaLLTgc6jLtgL9 eXOjlpkr45umzNYfnvSEcfh6jexgaKDZl+e7RsmIWSqX3RO8+YBZ48VtbF4MC5QaaM7L XOdGvEynhthhfaDyewdsJyhguGFGTRwgPG5STf0db4sVmOdC1/t4Vkgg1GyjAVnvugIp gP5CByKEyjlomYJ8eecNEuEBtxuJcmRx61QQ2Pjew0bCVX8Od/usrvizNu3e2wJopX+O jlnQ== X-Gm-Message-State: APjAAAXJ3IeFtAZAFL1Red45Fi5S3r2Mg9weE48nqhXVvNIa1YlODHQF waGsMAL19QQZO3hXIRv/tUU= X-Google-Smtp-Source: APXvYqyX7XAbGO/BUSR5X35Cw9AHSwDhRRkjMy4wE0zfriRWnFmzs7vmkDcxj9/qRp/WecFZalwX9Q== X-Received: by 2002:a1c:bcd6:: with SMTP id m205mr631830wmf.129.1568666860528; Mon, 16 Sep 2019 13:47:40 -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.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:40 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-ide@vger.kernel.org, Bartlomiej Zolnierkiewicz , Jens Axboe Subject: [PATCH v3 22/26] pata_atp867x: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:54 +0300 Message-Id: <20190916204158.6889-23-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Bartlomiej Zolnierkiewicz Cc: Jens Axboe Signed-off-by: Denis Efremov --- drivers/ata/pata_atp867x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c index 2b9ed4ddef8d..019198eb7099 100644 --- a/drivers/ata/pata_atp867x.c +++ b/drivers/ata/pata_atp867x.c @@ -422,7 +422,7 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host) #ifdef ATP867X_DEBUG atp867x_check_res(pdev); - for (i = 0; i < PCI_ROM_RESOURCE; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) printk(KERN_DEBUG "ATP867X: iomap[%d]=0x%llx\n", i, (unsigned long long)(host->iomap[i])); #endif From patchwork Mon Sep 16 20:41:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147815 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8DC814ED for ; Mon, 16 Sep 2019 20:47:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F0DC206A4 for ; Mon, 16 Sep 2019 20:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727971AbfIPUrp (ORCPT ); Mon, 16 Sep 2019 16:47:45 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38106 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391655AbfIPUrp (ORCPT ); Mon, 16 Sep 2019 16:47:45 -0400 Received: by mail-wm1-f68.google.com with SMTP id o184so706934wme.3; Mon, 16 Sep 2019 13:47:43 -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=3cjyw4iwufFr2TJPexscuSdiVbwU5mYSUwRk7WraBNI=; b=Tr8MstYMiKd76A0jbU81wmUaK3mG8bOCOCjqAnKQjMSzM3+p2IOo5VlN3LLNoZYRz7 F7ed+xbcJCdl9c/jcME5w2fghr7deqNSw2HjuoHdzPszgI3r7EC+4o7UkOMFKfIfJhvo R3gwvYk5yp75qXdfUffW3miAEUXLB5q2QpHL0c+NsOWXho2EwtZ4vczH5+1desM3SclK 13o+sPa2AwU87ktvHDAvBQe2vQKDNM4m3OOsKHYCDc31PpV3fFJj/Jq+VLJU0zfPwItN cUuUuSZGmo37JjYW3ekQmRzJCgKsBXcJlQ1A3orreoXs1V/h/uxCl0ke2Pl2Oe+hy8el ayhA== X-Gm-Message-State: APjAAAXnBT2PeyZnnbmXKyWJFHvGxqpYbBJp8QX/0C8oxERBwGXSlrRc RS6kh0bqaR7wgQItHA1Tazjv+AMxhEs= X-Google-Smtp-Source: APXvYqzMPwcH5G6tl3Joo+Hv1PKsJgaFKV0jqz+iiMxqYzKNshopG5ryQA7iKmg12oFq25aYnYYLhA== X-Received: by 2002:a1c:9615:: with SMTP id y21mr704785wmd.5.1568666863156; Mon, 16 Sep 2019 13:47:43 -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.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:42 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-mmc@vger.kernel.org, Maxim Levitsky , Alex Dubov , Ulf Hansson Subject: [PATCH v3 23/26] memstick: use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:55 +0300 Message-Id: <20190916204158.6889-24-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Maxim Levitsky Cc: Alex Dubov Cc: Ulf Hansson Signed-off-by: Denis Efremov Acked-by: Ulf Hansson --- drivers/memstick/host/jmb38x_ms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c index 32747425297d..fd281c1d39b1 100644 --- a/drivers/memstick/host/jmb38x_ms.c +++ b/drivers/memstick/host/jmb38x_ms.c @@ -848,7 +848,7 @@ static int jmb38x_ms_count_slots(struct pci_dev *pdev) { int cnt, rc = 0; - for (cnt = 0; cnt < PCI_ROM_RESOURCE; ++cnt) { + for (cnt = 0; cnt < PCI_STD_NUM_BARS; ++cnt) { if (!(IORESOURCE_MEM & pci_resource_flags(pdev, cnt))) break; From patchwork Mon Sep 16 20:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147823 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA76114E5 for ; Mon, 16 Sep 2019 20:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9A73214AF for ; Mon, 16 Sep 2019 20:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391681AbfIPUru (ORCPT ); Mon, 16 Sep 2019 16:47:50 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36822 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391655AbfIPUrt (ORCPT ); Mon, 16 Sep 2019 16:47:49 -0400 Received: by mail-wm1-f68.google.com with SMTP id t3so716561wmj.1; Mon, 16 Sep 2019 13:47:47 -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=jRXIYYCqTzf80wPMvUGVQBZL1Q1d4vGLXXoDHnC/zIQ=; b=qp/sC5unG5ESbvaTRsJ7m6SuOgxTQQ8ptk6BtJaCJOi/z2Drew6QEZ3u6tBxFH0dXW CNHsR1nohingnN7POvKiQpN0MLFQJB9ELBF1uuNACbQB+312oSM3HPhrflvPDsfRcyh3 Jkjv6fPfJe3Z8adxBhREj+jaZEHDc8KXtHjVLvnW+/HEk9t5iAc+6PURQzQ/3/MBglFs xCrs0ROx+VFSA7gFlfE3pLXPUQh5xGpUwigFGTt6+LvrL1uTtw/++WSnlVCMCl6g94fF WNKBbpP5GzS4lLYcnP1ciJbt8ebHeEzlJERuKg1iXi3QisxICDwXGI+SV/qxkGaisIZ4 hvAA== X-Gm-Message-State: APjAAAVNGSKoiSmoN4cR1lJ+C/D+SqHNC5koJvE+4/jzaFpCS9WhatZb JYAKh140ffiyFnRr9fLfCDk= X-Google-Smtp-Source: APXvYqwTkEolBF+4/h20FKyB+xWEOb8/ZOCtjD6dCrukuPGeL6pmmum3arJeC1C9cYldAM8ty7ZNwQ== X-Received: by 2002:a1c:9ecb:: with SMTP id h194mr645276wme.35.1568666867296; Mon, 16 Sep 2019 13:47:47 -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.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:46 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-usb@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH v3 24/26] USB: core: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:56 +0300 Message-Id: <20190916204158.6889-25-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Greg Kroah-Hartman Signed-off-by: Denis Efremov --- drivers/usb/core/hcd-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 7537681355f6..3a79e8623d66 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -234,7 +234,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) /* UHCI */ int region; - for (region = 0; region < PCI_ROM_RESOURCE; region++) { + for (region = 0; region < PCI_STD_NUM_BARS; region++) { if (!(pci_resource_flags(dev, region) & IORESOURCE_IO)) continue; From patchwork Mon Sep 16 20:41:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147819 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AF6614ED for ; Mon, 16 Sep 2019 20:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42D0E214AF for ; Mon, 16 Sep 2019 20:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391655AbfIPUrw (ORCPT ); Mon, 16 Sep 2019 16:47:52 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34066 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391687AbfIPUrw (ORCPT ); Mon, 16 Sep 2019 16:47:52 -0400 Received: by mail-wm1-f66.google.com with SMTP id y135so871409wmc.1; Mon, 16 Sep 2019 13:47:50 -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=52Ok3SbrITEZp2+/epaFkzm4cA6Xg3yiQs6lhoB6dtE=; b=QmsRC2A8rWI/D2+psCaMFTL1158kKui/MBsjBR58T+JdQxzO46kpmZD0gNZASTt1Su FRfLbAhaaXZvwNJBBuY9Ek/0YgdRycz7TJT7OrBL88RYtoJ3Rropdy0IEfhkbpsDtzxA CtL2mLD5WJbpDYLuenOieIYXjTixnzapYY0qS3ZZVY4WRsgwDzUwPkMBwqdb/O50gvJz bBzNBgJUhQDFjrusqKUCdvo6Mdh53m2fw0zMld/z9IbRD9qoQ0Oaa7S98seYgT/PMP/y A9CJ9sMFBdgdCqEB4L3622CaPT1DlbPmBoIJHlCRkugpMyfHHgl3tAAcetT9nlUHfQfy jMEw== X-Gm-Message-State: APjAAAUMagXesZsU+yNwgfK8C4AVifxWE4RM0CEvdbV3jnSCMYXFKl1d jwgwfJxxp6cD9gBVkdfiabA= X-Google-Smtp-Source: APXvYqz6Jmo3KBQBa3LCnNmy1P65ruQhcV1dGeEJa0J9si07nknK6v9wQUPUY21xKRf/Wf3b3Yux/Q== X-Received: by 2002:a1c:7c0b:: with SMTP id x11mr675946wmc.92.1568666869752; Mon, 16 Sep 2019 13:47:49 -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.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:49 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , linux-usb@vger.kernel.org, Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v3 25/26] usb: pci-quirks: Use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:57 +0300 Message-Id: <20190916204158.6889-26-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Mathias Nyman Cc: Greg Kroah-Hartman Signed-off-by: Denis Efremov --- drivers/usb/host/pci-quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index f6d04491df60..6c7f0a876b96 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -728,7 +728,7 @@ static void quirk_usb_handoff_uhci(struct pci_dev *pdev) if (!pio_enabled(pdev)) return; - for (i = 0; i < PCI_ROM_RESOURCE; i++) + for (i = 0; i < PCI_STD_NUM_BARS; i++) if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) { base = pci_resource_start(pdev, i); break; From patchwork Mon Sep 16 20:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11147821 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0F9B14E5 for ; Mon, 16 Sep 2019 20:48:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9210214AF for ; Mon, 16 Sep 2019 20:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbfIPUr4 (ORCPT ); Mon, 16 Sep 2019 16:47:56 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39084 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732405AbfIPUr4 (ORCPT ); Mon, 16 Sep 2019 16:47:56 -0400 Received: by mail-wr1-f67.google.com with SMTP id r3so837246wrj.6; Mon, 16 Sep 2019 13:47:54 -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=9mHQn9yr9ukPszYJrf03cNkjP7/MXLX6PUP4ZK8/EQw=; b=AsNs4BJ22RLrJfUZLd5+zl7vDYpqTPyLlH7LNo55QbbAsSiba41+32EkMl1y4WHyNL 6jlotrJlCm5cfCqhqbz/idlPtwRQ6GS09BpA5e6om8X7KYyzNfx4mzUzOHkKvw1F6Osu VVH1coUrLZ9fLkAXDqKqq5WR2z9wxyFAbj5jXBc7l0EZdWUeMebBxxqGlsmhYf2ykmtI rTFdyJj4OJzD/bA7nZTScnpe43EcCO/LvOU9d5ryPX1GPj0Rsdx8l+WBntVXt1tN6r/H nr82aT5ja7eW9CO1Mk01B14gqZ57MnojzU3SLJF4DrtwBavqz6nM+oBd9XUMjlZqzvLz 6hag== X-Gm-Message-State: APjAAAV8wXlW/AvnFTZ43mBJhF9ure9i8yogRmcd5gNDf8/eYjN2C8Xs yhKZNK1JYlDBVrWPKtxOQ7A= X-Google-Smtp-Source: APXvYqx33KDcFK0Om4/tnCLMJ86ojpQA68+cViMbTRgcRz3yunFkKYXsiLmKSzvLZ+f1yeXDeqcFuA== X-Received: by 2002:adf:e7c2:: with SMTP id e2mr166037wrn.319.1568666874026; Mon, 16 Sep 2019 13:47:54 -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.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:47:53 -0700 (PDT) From: Denis Efremov To: Bjorn Helgaas Cc: Denis Efremov , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Andrew Murray , Greg Kroah-Hartman Subject: [PATCH v3 26/26] devres: use PCI_STD_NUM_BARS Date: Mon, 16 Sep 2019 23:41:58 +0300 Message-Id: <20190916204158.6889-27-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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use define PCI_STD_NUM_BARS instead of PCI_ROM_RESOURCE for the number of PCI BARs. Cc: Greg Kroah-Hartman Signed-off-by: Denis Efremov --- lib/devres.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devres.c b/lib/devres.c index 6a0e9bd6524a..ab75d73122b8 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -262,7 +262,7 @@ EXPORT_SYMBOL(devm_ioport_unmap); /* * PCI iomap devres */ -#define PCIM_IOMAP_MAX PCI_ROM_RESOURCE +#define PCIM_IOMAP_MAX PCI_STD_NUM_BARS struct pcim_iomap_devres { void __iomem *table[PCIM_IOMAP_MAX];