aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-02 08:18:54 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-16 19:25:37 -0500
commit222831787704c9ad9215f6b56f975b233968607c (patch)
treed5b2490fa6f15c7a781d3951aeaeb18a27872c53 /arch/mips
parent6e783865b4e60f2ecf7708f8ea24db5c5ea07ced (diff)
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 <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4910/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/pci/pci.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index a1843448fad3..eb653994a2f1 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -175,9 +175,20 @@ static DEFINE_MUTEX(pci_scan_mutex);
175 175
176void register_pci_controller(struct pci_controller *hose) 176void register_pci_controller(struct pci_controller *hose)
177{ 177{
178 if (request_resource(&iomem_resource, hose->mem_resource) < 0) 178 struct resource *parent;
179
180 parent = hose->mem_resource->parent;
181 if (!parent)
182 parent = &iomem_resource;
183
184 if (request_resource(parent, hose->mem_resource) < 0)
179 goto out; 185 goto out;
180 if (request_resource(&ioport_resource, hose->io_resource) < 0) { 186
187 parent = hose->io_resource->parent;
188 if (!parent)
189 parent = &ioport_resource;
190
191 if (request_resource(parent, hose->io_resource) < 0) {
181 release_resource(hose->mem_resource); 192 release_resource(hose->mem_resource);
182 goto out; 193 goto out;
183 } 194 }