ar71xx: refactor PCI code to allow registering multiple PCI controllers
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.3 / 148-MIPS-avoid-possible-resource-conflict-in-register_pc.patch
1 From a018b28d3953a32008de839d997a992a724ae314 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sun, 24 Jun 2012 17:40:45 +0200
4 Subject: [PATCH 09/34] MIPS: avoid possible resource conflict in register_pci_controller
5
6 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
7 ---
8 arch/mips/pci/pci.c | 15 +++++++++++++--
9 1 files changed, 13 insertions(+), 2 deletions(-)
10
11 --- a/arch/mips/pci/pci.c
12 +++ b/arch/mips/pci/pci.c
13 @@ -127,9 +127,20 @@ static DEFINE_MUTEX(pci_scan_mutex);
14
15 void __devinit register_pci_controller(struct pci_controller *hose)
16 {
17 - if (request_resource(&iomem_resource, hose->mem_resource) < 0)
18 + struct resource *parent;
19 +
20 + parent = hose->mem_resource->parent;
21 + if (!parent)
22 + parent = &iomem_resource;
23 +
24 + if (request_resource(parent, hose->mem_resource) < 0)
25 goto out;
26 - if (request_resource(&ioport_resource, hose->io_resource) < 0) {
27 +
28 + parent = hose->io_resource->parent;
29 + if (!parent)
30 + parent = &ioport_resource;
31 +
32 + if (request_resource(parent, hose->io_resource) < 0) {
33 release_resource(hose->mem_resource);
34 goto out;
35 }