]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2o: Use pci_bus_alloc_resource(), not allocate_resource() directly
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 26 Feb 2014 18:25:57 +0000 (11:25 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 26 Feb 2014 21:41:17 +0000 (14:41 -0700)
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>
drivers/message/i2o/iop.c

index bd971b1b88e3be293398d4166486463859a30692..92752fb5b2d3d8b41364261a99eb44938e33be32 100644 (file)
@@ -655,8 +655,8 @@ static int i2o_iop_activate(struct i2o_controller *c)
 static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
 {
        i2o_status_block *sb = c->status_block.virt;
-       struct resource *root, *res = &c->mem_resource;
-       resource_size_t size, min, max, align;
+       struct resource *res = &c->mem_resource;
+       resource_size_t size, align;
        int err;
 
        res->name = c->pdev->bus->name;
@@ -664,21 +664,17 @@ static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
        res->start = 0;
        res->end = 0;
        osm_info("%s: requires private memory resources.\n", c->name);
-       root = pci_find_parent_resource(c->pdev, res);
-       if (root == NULL) {
-               osm_warn("%s: Can't find parent resource!\n", c->name);
-               return;
-       }
 
        if (flags & IORESOURCE_MEM) {
-               size = min = max = sb->desired_mem_size;
+               size = sb->desired_mem_size;
                align = 1 << 20;        /* unspecified, use 1Mb and play safe */
        } else {
-               size = min = max = sb->desired_io_size;
+               size = sb->desired_io_size;
                align = 1 << 12;        /* unspecified, use 4Kb and play safe */
        }
 
-       err = allocate_resource(root, res, size, min, max, align, NULL, NULL);
+       err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0,
+                                    NULL, NULL);
        if (err < 0)
                return;