diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2021-09-02 14:56:43 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2021-09-02 14:56:43 -0500 |
commit | 9045f63e67bc91f02be245346fff9fb9703e7a3c (patch) | |
tree | 6012b02f9620067773ca01d2b9db485151d6bbb8 /drivers/pci/pci.c | |
parent | e210d9fc0903e83aa018a32227f7ff529e593004 (diff) | |
parent | ca32b5310a1a3835f81f498367f1bb7450c8b67b (diff) |
Merge branch 'pci/resource'
- Refactor pci_ioremap_bar() and pci_ioremap_wc_bar() (Krzysztof
WilczyĆski)
- Optimize pci_resource_len() to reduce kernel size (Zhen Lei)
* pci/resource:
PCI: Optimize pci_resource_len() to reduce kernel size
PCI: Refactor pci_ioremap_bar() and pci_ioremap_wc_bar()
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b87bac5e4572..8e594c3a0e4d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -212,32 +212,36 @@ int pci_status_get_and_clear_errors(struct pci_dev *pdev) EXPORT_SYMBOL_GPL(pci_status_get_and_clear_errors); #ifdef CONFIG_HAS_IOMEM -void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) +static void __iomem *__pci_ioremap_resource(struct pci_dev *pdev, int bar, + bool write_combine) { struct resource *res = &pdev->resource[bar]; + resource_size_t start = res->start; + resource_size_t size = resource_size(res); /* * Make sure the BAR is actually a memory resource, not an IO resource */ if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { - pci_warn(pdev, "can't ioremap BAR %d: %pR\n", bar, res); + pci_err(pdev, "can't ioremap BAR %d: %pR\n", bar, res); return NULL; } - return ioremap(res->start, resource_size(res)); + + if (write_combine) + return ioremap_wc(start, size); + + return ioremap(start, size); +} + +void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) +{ + return __pci_ioremap_resource(pdev, bar, false); } EXPORT_SYMBOL_GPL(pci_ioremap_bar); void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar) { - /* - * Make sure the BAR is actually a memory resource, not an IO resource - */ - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { - WARN_ON(1); - return NULL; - } - return ioremap_wc(pci_resource_start(pdev, bar), - pci_resource_len(pdev, bar)); + return __pci_ioremap_resource(pdev, bar, true); } EXPORT_SYMBOL_GPL(pci_ioremap_wc_bar); #endif |