[PATCH v4 14/24] alpha/PCI: Clean up pci_mmap_resource()

Krzysztof Wilczyński
2026-04-11T08:02:42Z

Replace open-coded res->flags type checks with new pci_resource_is_mem()
and pci_resource_start() helpers. Move the pci_resource_n() call into
pcibios_resource_to_bus() and drop the local struct resource pointer.

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
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 7aac5e76dcd6..6c011dab326d 100644
--- a/arch/alpha/kernel/pci-sysfs.c
+++ b/arch/alpha/kernel/pci-sysfs.c
@@ -70,7 +70,6 @@ static int pci_mmap_resource(struct kobject *kobj,
{
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
int barno = (unsigned long)attr->private;
- struct resource *res = pci_resource_n(pdev, barno);
enum pci_mmap_state mmap_type;
struct pci_bus_region bar;
int ret;
@@ -79,15 +78,16 @@ static int pci_mmap_resource(struct kobject *kobj,
if (ret)
return ret;

- if ((res->flags & IORESOURCE_MEM) && iomem_is_exclusive(res->start))
+ if (pci_resource_is_mem(pdev, barno) &&
+ iomem_is_exclusive(pci_resource_start(pdev, barno)))
return -EINVAL;

if (!__pci_mmap_fits(pdev, barno, vma, sparse))
return -EINVAL;

- pcibios_resource_to_bus(pdev->bus, &bar, res);
+ pcibios_resource_to_bus(pdev->bus, &bar, pci_resource_n(pdev, barno));
vma->vm_pgoff += bar.start >> (PAGE_SHIFT - (sparse ? 5 : 0));
- mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
+ mmap_type = pci_resource_is_mem(pdev, barno) ? pci_mmap_mem : pci_mmap_io;

return hose_mmap_page_range(pdev->sysdata, vma, mmap_type, sparse);
}
--
2.53.0