ar71xx: move the watchdog driver to the kernel
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.8 / 015-MIPS-avoid-possible-resource-conflict-in-register_pc.patch
1 From 4da85831c8eaf2de2cadae6723e8231068c313b7 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sat, 2 Feb 2013 13:18:54 +0000
4 Subject: [PATCH] MIPS: avoid possible resource conflict in
5 register_pci_controller
6
7 commit 222831787704c9ad9215f6b56f975b233968607c upstream.
8
9 The IO and memory resources of a PCI controller
10 might already have a parent resource set when
11 they are passed to 'register_pci_controller'.
12
13 If the parent resource is set, the request_resource
14 call will fail due to resource conflict and the
15 current code will not be able to register the
16 PCI controller.
17
18 Use the parent resource if it is available in the
19 request_resource call to avoid the isssue.
20
21 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
22 Patchwork: http://patchwork.linux-mips.org/patch/4910/
23 Signed-off-by: John Crispin <blogic@openwrt.org>
24 ---
25 arch/mips/pci/pci.c | 15 +++++++++++++--
26 1 file changed, 13 insertions(+), 2 deletions(-)
27
28 --- a/arch/mips/pci/pci.c
29 +++ b/arch/mips/pci/pci.c
30 @@ -181,9 +181,20 @@ static DEFINE_MUTEX(pci_scan_mutex);
31
32 void register_pci_controller(struct pci_controller *hose)
33 {
34 - if (request_resource(&iomem_resource, hose->mem_resource) < 0)
35 + struct resource *parent;
36 +
37 + parent = hose->mem_resource->parent;
38 + if (!parent)
39 + parent = &iomem_resource;
40 +
41 + if (request_resource(parent, hose->mem_resource) < 0)
42 goto out;
43 - if (request_resource(&ioport_resource, hose->io_resource) < 0) {
44 +
45 + parent = hose->io_resource->parent;
46 + if (!parent)
47 + parent = &ioport_resource;
48 +
49 + if (request_resource(parent, hose->io_resource) < 0) {
50 release_resource(hose->mem_resource);
51 goto out;
52 }