On Fri, 10 Apr 2026, Krzysztof Wilczyński wrote:

> 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 <[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 16eaaf749ba9..ad3c17f86c7f 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 */
> @@ -715,7 +715,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);
> @@ -1108,7 +1108,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);
> @@ -1312,7 +1312,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);
> 

Reviewed-by: Ilpo Järvinen <[email protected]>

-- 
 i.

Reply via email to