Replace direct pdev->resource[] accesses with pci_resource_n(),
and pdev->resource[].flags accesses with pci_resource_flags().

No functional changes intended.

Tested-by: Shivaprasad G Bhat <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Krzysztof Wilczyński <[email protected]>
---
 drivers/pci/pci-sysfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d37860841260..1fbc3daf87cc 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -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);
-- 
2.54.0


Reply via email to