From: Gabor Juhos Date: Sat, 2 Feb 2013 13:18:54 +0000 (+0000) Subject: MIPS: avoid possible resource conflict in register_pci_controller X-Git-Tag: v3.9-rc1~26^2~1^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=222831787704c9ad9215f6b56f975b233968607c;p=profile%2Fivi%2Fkernel-x86-ivi.git MIPS: avoid possible resource conflict in register_pci_controller The IO and memory resources of a PCI controller might already have a parent resource set when they are passed to 'register_pci_controller'. If the parent resource is set, the request_resource call will fail due to resource conflict and the current code will not be able to register the PCI controller. Use the parent resource if it is available in the request_resource call to avoid the isssue. Signed-off-by: Gabor Juhos Patchwork: http://patchwork.linux-mips.org/patch/4910/ Signed-off-by: John Crispin --- diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index a184344..eb65399 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c @@ -175,9 +175,20 @@ static DEFINE_MUTEX(pci_scan_mutex); void register_pci_controller(struct pci_controller *hose) { - if (request_resource(&iomem_resource, hose->mem_resource) < 0) + struct resource *parent; + + parent = hose->mem_resource->parent; + if (!parent) + parent = &iomem_resource; + + if (request_resource(parent, hose->mem_resource) < 0) goto out; - if (request_resource(&ioport_resource, hose->io_resource) < 0) { + + parent = hose->io_resource->parent; + if (!parent) + parent = &ioport_resource; + + if (request_resource(parent, hose->io_resource) < 0) { release_resource(hose->mem_resource); goto out; }