ppc32: Fix release_OF_resource() function.

It would fail to properly release the resource if taken over
by the macio device resource hierarchy. This could still use
some locking, but the io resource lock isn't exported
parent f74710a0
...@@ -1212,8 +1212,6 @@ find_parent_pci_resource(struct pci_dev* pdev, struct address_range *range) ...@@ -1212,8 +1212,6 @@ find_parent_pci_resource(struct pci_dev* pdev, struct address_range *range)
* Request an OF device resource. Currently handles child of PCI devices, * Request an OF device resource. Currently handles child of PCI devices,
* or other nodes attached to the root node. Ultimately, put some * or other nodes attached to the root node. Ultimately, put some
* link to resources in the OF node. * link to resources in the OF node.
* WARNING: out_resource->name should be initialized before calling this
* function.
*/ */
struct resource* __openfirmware struct resource* __openfirmware
request_OF_resource(struct device_node* node, int index, const char* name_postfix) request_OF_resource(struct device_node* node, int index, const char* name_postfix)
...@@ -1276,7 +1274,7 @@ release_OF_resource(struct device_node* node, int index) ...@@ -1276,7 +1274,7 @@ release_OF_resource(struct device_node* node, int index)
{ {
struct pci_dev* pcidev; struct pci_dev* pcidev;
u8 pci_bus, pci_devfn; u8 pci_bus, pci_devfn;
unsigned long iomask; unsigned long iomask, start, end;
struct device_node* nd; struct device_node* nd;
struct resource* parent; struct resource* parent;
struct resource *res = NULL; struct resource *res = NULL;
...@@ -1305,18 +1303,23 @@ release_OF_resource(struct device_node* node, int index) ...@@ -1305,18 +1303,23 @@ release_OF_resource(struct device_node* node, int index)
if (pcidev) if (pcidev)
parent = find_parent_pci_resource(pcidev, &node->addrs[index]); parent = find_parent_pci_resource(pcidev, &node->addrs[index]);
if (!parent) { if (!parent) {
printk(KERN_WARNING "request_OF_resource(%s), parent not found\n", printk(KERN_WARNING "release_OF_resource(%s), parent not found\n",
node->name); node->name);
return -ENODEV; return -ENODEV;
} }
/* Find us in the parent */ /* Find us in the parent and its childs */
res = parent->child; res = parent->child;
start = node->addrs[index].address;
end = start + node->addrs[index].size - 1;
while (res) { while (res) {
if (res->start == node->addrs[index].address && if (res->start == start && res->end == end &&
res->end == (res->start + node->addrs[index].size - 1)) (res->flags & IORESOURCE_BUSY))
break; break;
res = res->sibling; if (res->start <= start && res->end >= end)
res = res->child;
else
res = res->sibling;
} }
if (!res) if (!res)
return -ENODEV; return -ENODEV;
......
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