Commit a76117df authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

x86: Use pci_claim_resource

Instead of open-coding pci_find_parent_resource and request_resource,
just call pci_claim_resource.
Signed-off-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a6c14096
...@@ -116,7 +116,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) ...@@ -116,7 +116,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
struct pci_bus *bus; struct pci_bus *bus;
struct pci_dev *dev; struct pci_dev *dev;
int idx; int idx;
struct resource *r, *pr; struct resource *r;
/* Depth-First Search on bus tree */ /* Depth-First Search on bus tree */
list_for_each_entry(bus, bus_list, node) { list_for_each_entry(bus, bus_list, node) {
...@@ -126,9 +126,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) ...@@ -126,9 +126,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
r = &dev->resource[idx]; r = &dev->resource[idx];
if (!r->flags) if (!r->flags)
continue; continue;
pr = pci_find_parent_resource(dev, r); if (!r->start ||
if (!r->start || !pr || pci_claim_resource(dev, idx) < 0) {
request_resource(pr, r) < 0) {
dev_info(&dev->dev, "BAR %d: can't allocate resource\n", idx); dev_info(&dev->dev, "BAR %d: can't allocate resource\n", idx);
/* /*
* Something is wrong with the region. * Something is wrong with the region.
...@@ -149,7 +148,7 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -149,7 +148,7 @@ static void __init pcibios_allocate_resources(int pass)
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
int idx, disabled; int idx, disabled;
u16 command; u16 command;
struct resource *r, *pr; struct resource *r;
for_each_pci_dev(dev) { for_each_pci_dev(dev) {
pci_read_config_word(dev, PCI_COMMAND, &command); pci_read_config_word(dev, PCI_COMMAND, &command);
...@@ -168,8 +167,7 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -168,8 +167,7 @@ static void __init pcibios_allocate_resources(int pass)
(unsigned long long) r->start, (unsigned long long) r->start,
(unsigned long long) r->end, (unsigned long long) r->end,
r->flags, disabled, pass); r->flags, disabled, pass);
pr = pci_find_parent_resource(dev, r); if (pci_claim_resource(dev, idx) < 0) {
if (!pr || request_resource(pr, r) < 0) {
dev_info(&dev->dev, "BAR %d: can't allocate resource\n", idx); dev_info(&dev->dev, "BAR %d: can't allocate resource\n", idx);
/* We'll assign a new address later */ /* We'll assign a new address later */
r->end -= r->start; r->end -= r->start;
...@@ -197,7 +195,7 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -197,7 +195,7 @@ static void __init pcibios_allocate_resources(int pass)
static int __init pcibios_assign_resources(void) static int __init pcibios_assign_resources(void)
{ {
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
struct resource *r, *pr; struct resource *r;
if (!(pci_probe & PCI_ASSIGN_ROMS)) { if (!(pci_probe & PCI_ASSIGN_ROMS)) {
/* /*
...@@ -209,8 +207,7 @@ static int __init pcibios_assign_resources(void) ...@@ -209,8 +207,7 @@ static int __init pcibios_assign_resources(void)
r = &dev->resource[PCI_ROM_RESOURCE]; r = &dev->resource[PCI_ROM_RESOURCE];
if (!r->flags || !r->start) if (!r->flags || !r->start)
continue; continue;
pr = pci_find_parent_resource(dev, r); if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
if (!pr || request_resource(pr, r) < 0) {
r->end -= r->start; r->end -= r->start;
r->start = 0; r->start = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment