]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI/sysfs: Use PCI resource accessor macros
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:20 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 8 May 2026 22:43:56 +0000 (17:43 -0500)
Replace direct pdev->resource[] accesses with pci_resource_n(), and
pdev->resource[].flags accesses with pci_resource_flags().

No functional changes intended.

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://patch.msgid.link/20260508043543.217179-2-kwilczynski@kernel.org
drivers/pci/pci-sysfs.c

index d37860841260ce53fc9032241fbf89bc56ed7f41..1fbc3daf87cc57734f19f3b8ceb2977fe39f03cc 100644 (file)
@@ -177,7 +177,7 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
                max = PCI_BRIDGE_RESOURCES;
 
        for (i = 0; i < max; i++) {
-               struct resource *res =  &pci_dev->resource[i];
+               struct resource *res = pci_resource_n(pci_dev, i);
                struct resource zerores = {};
 
                /* For backwards compatibility */
@@ -689,7 +689,7 @@ static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
                return sysfs_emit(buf, "%u\n", (pdev == vga_dev));
 
        return sysfs_emit(buf, "%u\n",
-                         !!(pdev->resource[PCI_ROM_RESOURCE].flags &
+                         !!(pci_resource_flags(pdev, PCI_ROM_RESOURCE) &
                             IORESOURCE_ROM_SHADOW));
 }
 static DEVICE_ATTR_RO(boot_vga);
@@ -1082,7 +1082,7 @@ static int pci_mmap_resource(struct kobject *kobj, const struct bin_attribute *a
        struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
        int bar = (unsigned long)attr->private;
        enum pci_mmap_state mmap_type;
-       struct resource *res = &pdev->resource[bar];
+       struct resource *res = pci_resource_n(pdev, bar);
        int ret;
 
        ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
@@ -1286,7 +1286,7 @@ static int pci_create_resource_files(struct pci_dev *pdev)
                retval = pci_create_attr(pdev, i, 0);
                /* for prefetchable resources, create a WC mappable file */
                if (!retval && arch_can_pci_mmap_wc() &&
-                   pdev->resource[i].flags & IORESOURCE_PREFETCH)
+                   pci_resource_flags(pdev, i) & IORESOURCE_PREFETCH)
                        retval = pci_create_attr(pdev, i, 1);
                if (retval) {
                        pci_remove_resource_files(pdev);