aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko2023-03-30 19:24:29 +0300
committerBjorn Helgaas2023-04-04 10:43:20 -0500
commit144d204df78e40e6250201e71ef7d0e42d2a13fc (patch)
treebdc2270eb7885df618cde8784121e1f85b299087
parentfe15c26ee26efa11741a7b632e9f23b01aca4cc6 (diff)
PCI: Introduce pci_resource_n()
Introduce pci_resource_n() and replace open-coded implementations of it in pci.h. Link: https://lore.kernel.org/r/20230330162434.35055-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
-rw-r--r--include/linux/pci.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fafd8020c6d7..0239f12d0ba9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1994,14 +1994,13 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
* These helpers provide future and backwards compatibility
* for accessing popular PCI BAR info
*/
-#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
-#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
-#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
-#define pci_resource_len(dev,bar) \
- ((pci_resource_end((dev), (bar)) == 0) ? 0 : \
- \
- (pci_resource_end((dev), (bar)) - \
- pci_resource_start((dev), (bar)) + 1))
+#define pci_resource_n(dev, bar) (&(dev)->resource[(bar)])
+#define pci_resource_start(dev, bar) (pci_resource_n(dev, bar)->start)
+#define pci_resource_end(dev, bar) (pci_resource_n(dev, bar)->end)
+#define pci_resource_flags(dev, bar) (pci_resource_n(dev, bar)->flags)
+#define pci_resource_len(dev,bar) \
+ (pci_resource_end((dev), (bar)) ? \
+ resource_size(pci_resource_n((dev), (bar))) : 0)
/*
* Similar to the helpers above, these manipulate per-pci_dev