Commit 5fa2f9fb authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Bjorn Helgaas
Browse files

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: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-11-ilpo.jarvinen@linux.intel.com
parent e112fbb2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
		struct resource zerores = {};

		/* For backwards compatibility */
		if (i >= PCI_BRIDGE_RESOURCES && i <= PCI_BRIDGE_RESOURCE_END &&
		if (pci_resource_is_bridge_win(i) &&
		    res->flags & (IORESOURCE_UNSET | IORESOURCE_DISABLED))
			res = &zerores;

+5 −0
Original line number Diff line number Diff line
@@ -452,6 +452,11 @@ void pci_walk_bus_locked(struct pci_bus *top,

const char *pci_resource_name(struct pci_dev *dev, unsigned int i);
bool pci_resource_is_optional(const struct pci_dev *dev, int resno);
static inline bool pci_resource_is_bridge_win(int resno)
{
	return resno >= PCI_BRIDGE_RESOURCES &&
	       resno <= PCI_BRIDGE_RESOURCE_END;
}

/**
 * pci_resource_num - Reverse lookup resource number from device resources
+3 −4
Original line number Diff line number Diff line
@@ -303,8 +303,7 @@ static bool pdev_resource_assignable(struct pci_dev *dev, struct resource *res)
	if (!res->flags)
		return false;

	if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END &&
	    res->flags & IORESOURCE_DISABLED)
	if (pci_resource_is_bridge_win(idx) && res->flags & IORESOURCE_DISABLED)
		return false;

	return true;
@@ -389,7 +388,7 @@ static inline void reset_resource(struct pci_dev *dev, struct resource *res)
{
	int idx = pci_resource_num(dev, res);

	if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END) {
	if (pci_resource_is_bridge_win(idx)) {
		res->flags |= IORESOURCE_UNSET;
		return;
	}
@@ -985,7 +984,7 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
{
	int ret = -EINVAL;

	if (i < PCI_BRIDGE_RESOURCES || i > PCI_BRIDGE_RESOURCE_END)
	if (!pci_resource_is_bridge_win(i))
		return 0;

	if (pci_claim_resource(bridge, i) == 0)
+1 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)

	res->flags &= ~IORESOURCE_UNSET;
	res->flags &= ~IORESOURCE_STARTALIGN;
	if (resno >= PCI_BRIDGE_RESOURCES && resno <= PCI_BRIDGE_RESOURCE_END)
	if (pci_resource_is_bridge_win(resno))
		res->flags &= ~IORESOURCE_DISABLED;

	pci_info(dev, "%s %pR: assigned\n", res_name, res);