Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7f4bbc9 authored by Yinghai Lu's avatar Yinghai Lu Committed by Bjorn Helgaas
Browse files

x86/PCI: Factor out pcibios_allocate_dev_resources()



Factor pcibios_allocate_dev_resources() out of
pcibios_allocate_resources().  Currently we only allocate these
resources at boot-time with a for_each_pci_dev() loop.  Eventually
we'll use pcibios_allocate_dev_resources() for hot-added devices, too.

[bhelgaas: changelog]
Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent f7ac356d
Loading
Loading
Loading
Loading
+23 −19
Original line number Original line Diff line number Diff line
@@ -232,9 +232,8 @@ struct pci_check_idx_range {
	int end;
	int end;
};
};


static void __init pcibios_allocate_resources(int pass)
static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
{
{
	struct pci_dev *dev = NULL;
	int idx, disabled, i;
	int idx, disabled, i;
	u16 command;
	u16 command;
	struct resource *r;
	struct resource *r;
@@ -246,7 +245,6 @@ static void __init pcibios_allocate_resources(int pass)
#endif
#endif
	};
	};


	for_each_pci_dev(dev) {
	pci_read_config_word(dev, PCI_COMMAND, &command);
	pci_read_config_word(dev, PCI_COMMAND, &command);
	for (i = 0; i < ARRAY_SIZE(idx_range); i++)
	for (i = 0; i < ARRAY_SIZE(idx_range); i++)
		for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) {
		for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) {
@@ -280,13 +278,19 @@ static void __init pcibios_allocate_resources(int pass)
			u32 reg;
			u32 reg;
			dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
			dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
			r->flags &= ~IORESOURCE_ROM_ENABLE;
			r->flags &= ~IORESOURCE_ROM_ENABLE;
				pci_read_config_dword(dev,
			pci_read_config_dword(dev, dev->rom_base_reg, &reg);
						dev->rom_base_reg, &reg);
			pci_write_config_dword(dev, dev->rom_base_reg,
			pci_write_config_dword(dev, dev->rom_base_reg,
						reg & ~PCI_ROM_ADDRESS_ENABLE);
						reg & ~PCI_ROM_ADDRESS_ENABLE);
		}
		}
	}
	}
}
}

static void __init pcibios_allocate_resources(int pass)
{
	struct pci_dev *dev = NULL;

	for_each_pci_dev(dev)
		pcibios_allocate_dev_resources(dev, pass);
}
}


static int __init pcibios_assign_resources(void)
static int __init pcibios_assign_resources(void)