diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-11-04 00:39:25 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-01-07 16:47:16 -0500 |
commit | c7f4bbc92feee2986212ef3b42c806e2257197dc (patch) | |
tree | 99c6a587123b3c5b4067f82ff1ad331a041b7fc1 /arch/x86/pci | |
parent | f7ac356dc3da1f69dc52cb6273e08e53b85b4884 (diff) |
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: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86/pci')
-rw-r--r-- | arch/x86/pci/i386.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 980036286909..5817cf235d9a 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -232,9 +232,8 @@ struct pci_check_idx_range { | |||
232 | int end; | 232 | int end; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | static void __init pcibios_allocate_resources(int pass) | 235 | static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) |
236 | { | 236 | { |
237 | struct pci_dev *dev = NULL; | ||
238 | int idx, disabled, i; | 237 | int idx, disabled, i; |
239 | u16 command; | 238 | u16 command; |
240 | struct resource *r; | 239 | struct resource *r; |
@@ -246,14 +245,13 @@ static void __init pcibios_allocate_resources(int pass) | |||
246 | #endif | 245 | #endif |
247 | }; | 246 | }; |
248 | 247 | ||
249 | for_each_pci_dev(dev) { | 248 | pci_read_config_word(dev, PCI_COMMAND, &command); |
250 | pci_read_config_word(dev, PCI_COMMAND, &command); | 249 | for (i = 0; i < ARRAY_SIZE(idx_range); i++) |
251 | for (i = 0; i < ARRAY_SIZE(idx_range); i++) | ||
252 | for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) { | 250 | for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) { |
253 | r = &dev->resource[idx]; | 251 | r = &dev->resource[idx]; |
254 | if (r->parent) /* Already allocated */ | 252 | if (r->parent) /* Already allocated */ |
255 | continue; | 253 | continue; |
256 | if (!r->start) /* Address not assigned at all */ | 254 | if (!r->start) /* Address not assigned at all */ |
257 | continue; | 255 | continue; |
258 | if (r->flags & IORESOURCE_IO) | 256 | if (r->flags & IORESOURCE_IO) |
259 | disabled = !(command & PCI_COMMAND_IO); | 257 | disabled = !(command & PCI_COMMAND_IO); |
@@ -272,23 +270,29 @@ static void __init pcibios_allocate_resources(int pass) | |||
272 | } | 270 | } |
273 | } | 271 | } |
274 | } | 272 | } |
275 | if (!pass) { | 273 | if (!pass) { |
276 | r = &dev->resource[PCI_ROM_RESOURCE]; | 274 | r = &dev->resource[PCI_ROM_RESOURCE]; |
277 | if (r->flags & IORESOURCE_ROM_ENABLE) { | 275 | if (r->flags & IORESOURCE_ROM_ENABLE) { |
278 | /* Turn the ROM off, leave the resource region, | 276 | /* Turn the ROM off, leave the resource region, |
279 | * but keep it unregistered. */ | 277 | * but keep it unregistered. */ |
280 | u32 reg; | 278 | u32 reg; |
281 | dev_dbg(&dev->dev, "disabling ROM %pR\n", r); | 279 | dev_dbg(&dev->dev, "disabling ROM %pR\n", r); |
282 | r->flags &= ~IORESOURCE_ROM_ENABLE; | 280 | r->flags &= ~IORESOURCE_ROM_ENABLE; |
283 | pci_read_config_dword(dev, | 281 | pci_read_config_dword(dev, dev->rom_base_reg, ®); |
284 | dev->rom_base_reg, ®); | 282 | pci_write_config_dword(dev, dev->rom_base_reg, |
285 | pci_write_config_dword(dev, dev->rom_base_reg, | ||
286 | reg & ~PCI_ROM_ADDRESS_ENABLE); | 283 | reg & ~PCI_ROM_ADDRESS_ENABLE); |
287 | } | ||
288 | } | 284 | } |
289 | } | 285 | } |
290 | } | 286 | } |
291 | 287 | ||
288 | static void __init pcibios_allocate_resources(int pass) | ||
289 | { | ||
290 | struct pci_dev *dev = NULL; | ||
291 | |||
292 | for_each_pci_dev(dev) | ||
293 | pcibios_allocate_dev_resources(dev, pass); | ||
294 | } | ||
295 | |||
292 | static int __init pcibios_assign_resources(void) | 296 | static int __init pcibios_assign_resources(void) |
293 | { | 297 | { |
294 | struct pci_dev *dev = NULL; | 298 | struct pci_dev *dev = NULL; |