diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2014-02-26 13:25:57 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-02-26 16:41:17 -0500 |
commit | d2e074ccbf84e91819ae07b3ca838120db2c97a9 (patch) | |
tree | 3234d2a5f5417d6ca51d99dbe59314cde7912575 /drivers/message/i2o | |
parent | 60f061e19311771e67a484184340e5359493f557 (diff) |
i2o: Use pci_bus_alloc_resource(), not allocate_resource() directly
Convert i2o_res_alloc() to use pci_bus_alloc_resource() rather than
pci_find_parent_resource() and allocate_resource(). We don't have a
resource to start with, so pci_find_parent_resource() can't do anything
useful: a bus may have several memory resources available, so there might
be several possible parents. This is more likely on root buses because
host bridges may have any number of apertures.
I'm pretty sure this didn't work in the first place because it passed
size == min == max to allocate_resource(). The min and max parameters are
constraints on the *addresses* of the resource, not on its size, so I think
it was impossible for allocate_resource() to succeed.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/message/i2o')
-rw-r--r-- | drivers/message/i2o/iop.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index bd971b1b88e3..92752fb5b2d3 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c | |||
@@ -655,8 +655,8 @@ static int i2o_iop_activate(struct i2o_controller *c) | |||
655 | static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags) | 655 | static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags) |
656 | { | 656 | { |
657 | i2o_status_block *sb = c->status_block.virt; | 657 | i2o_status_block *sb = c->status_block.virt; |
658 | struct resource *root, *res = &c->mem_resource; | 658 | struct resource *res = &c->mem_resource; |
659 | resource_size_t size, min, max, align; | 659 | resource_size_t size, align; |
660 | int err; | 660 | int err; |
661 | 661 | ||
662 | res->name = c->pdev->bus->name; | 662 | res->name = c->pdev->bus->name; |
@@ -664,21 +664,17 @@ static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags) | |||
664 | res->start = 0; | 664 | res->start = 0; |
665 | res->end = 0; | 665 | res->end = 0; |
666 | osm_info("%s: requires private memory resources.\n", c->name); | 666 | osm_info("%s: requires private memory resources.\n", c->name); |
667 | root = pci_find_parent_resource(c->pdev, res); | ||
668 | if (root == NULL) { | ||
669 | osm_warn("%s: Can't find parent resource!\n", c->name); | ||
670 | return; | ||
671 | } | ||
672 | 667 | ||
673 | if (flags & IORESOURCE_MEM) { | 668 | if (flags & IORESOURCE_MEM) { |
674 | size = min = max = sb->desired_mem_size; | 669 | size = sb->desired_mem_size; |
675 | align = 1 << 20; /* unspecified, use 1Mb and play safe */ | 670 | align = 1 << 20; /* unspecified, use 1Mb and play safe */ |
676 | } else { | 671 | } else { |
677 | size = min = max = sb->desired_io_size; | 672 | size = sb->desired_io_size; |
678 | align = 1 << 12; /* unspecified, use 4Kb and play safe */ | 673 | align = 1 << 12; /* unspecified, use 4Kb and play safe */ |
679 | } | 674 | } |
680 | 675 | ||
681 | err = allocate_resource(root, res, size, min, max, align, NULL, NULL); | 676 | err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0, |
677 | NULL, NULL); | ||
682 | if (err < 0) | 678 | if (err < 0) |
683 | return; | 679 | return; |
684 | 680 | ||