Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Add pci_resource_is_bridge_win()

Add pci_resource_is_bridge_win() helper to simplify checking if the
resource is a bridge window.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-11-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
5fa2f9fb e112fbb2

+10 -6
+1 -1
drivers/pci/pci-sysfs.c
··· 181 181 struct resource zerores = {}; 182 182 183 183 /* For backwards compatibility */ 184 - if (i >= PCI_BRIDGE_RESOURCES && i <= PCI_BRIDGE_RESOURCE_END && 184 + if (pci_resource_is_bridge_win(i) && 185 185 res->flags & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) 186 186 res = &zerores; 187 187
+5
drivers/pci/pci.h
··· 452 452 453 453 const char *pci_resource_name(struct pci_dev *dev, unsigned int i); 454 454 bool pci_resource_is_optional(const struct pci_dev *dev, int resno); 455 + static inline bool pci_resource_is_bridge_win(int resno) 456 + { 457 + return resno >= PCI_BRIDGE_RESOURCES && 458 + resno <= PCI_BRIDGE_RESOURCE_END; 459 + } 455 460 456 461 /** 457 462 * pci_resource_num - Reverse lookup resource number from device resources
+3 -4
drivers/pci/setup-bus.c
··· 303 303 if (!res->flags) 304 304 return false; 305 305 306 - if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END && 307 - res->flags & IORESOURCE_DISABLED) 306 + if (pci_resource_is_bridge_win(idx) && res->flags & IORESOURCE_DISABLED) 308 307 return false; 309 308 310 309 return true; ··· 388 389 { 389 390 int idx = pci_resource_num(dev, res); 390 391 391 - if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END) { 392 + if (pci_resource_is_bridge_win(idx)) { 392 393 res->flags |= IORESOURCE_UNSET; 393 394 return; 394 395 } ··· 984 985 { 985 986 int ret = -EINVAL; 986 987 987 - if (i < PCI_BRIDGE_RESOURCES || i > PCI_BRIDGE_RESOURCE_END) 988 + if (!pci_resource_is_bridge_win(i)) 988 989 return 0; 989 990 990 991 if (pci_claim_resource(bridge, i) == 0)
+1 -1
drivers/pci/setup-res.c
··· 359 359 360 360 res->flags &= ~IORESOURCE_UNSET; 361 361 res->flags &= ~IORESOURCE_STARTALIGN; 362 - if (resno >= PCI_BRIDGE_RESOURCES && resno <= PCI_BRIDGE_RESOURCE_END) 362 + if (pci_resource_is_bridge_win(resno)) 363 363 res->flags &= ~IORESOURCE_DISABLED; 364 364 365 365 pci_info(dev, "%s %pR: assigned\n", res_name, res);