aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Moffett <Kyle.D.Moffett@boeing.com>2011-12-02 01:28:02 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-06 21:43:07 -0500
commit996983b75cebb1bc1c2c545f20336f24ebfa17af (patch)
treeba137847233819cf043ef441420cf6e134ba557c
parente7a98675caf272a11dc1012c7a8c6c00cab09f5b (diff)
powerpc/mpic: Search for open-pic device-tree node if NULL
Almost all PowerPC platforms use a standard "open-pic" device node so the mpic_alloc() function now accepts NULL for the device-node. This will cause it to perform a default search with of_find_matching_node(). Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c10
-rw-r--r--arch/powerpc/platforms/85xx/ksi8560.c14
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c13
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c13
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c15
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c14
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c10
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_rdb.c14
-rw-r--r--arch/powerpc/platforms/85xx/p1010rdb.c12
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c14
-rw-r--r--arch/powerpc/platforms/85xx/p1023_rds.c11
-rw-r--r--arch/powerpc/platforms/85xx/sbc8548.c16
-rw-r--r--arch/powerpc/platforms/85xx/sbc8560.c13
-rw-r--r--arch/powerpc/platforms/85xx/socrates.c11
-rw-r--r--arch/powerpc/platforms/85xx/stx_gp3.c13
-rw-r--r--arch/powerpc/platforms/85xx/tqm85xx.c13
-rw-r--r--arch/powerpc/platforms/85xx/xes_mpc85xx.c13
-rw-r--r--arch/powerpc/platforms/86xx/pic.c11
-rw-r--r--arch/powerpc/platforms/embedded6xx/holly.c10
-rw-r--r--arch/powerpc/platforms/embedded6xx/linkstation.c8
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c10
-rw-r--r--arch/powerpc/platforms/embedded6xx/storcenter.c10
-rw-r--r--arch/powerpc/sysdev/mpic.c34
23 files changed, 58 insertions, 244 deletions
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 5b1c577199bf..cfa4bada7eb2 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,21 +36,13 @@
36void __init corenet_ds_pic_init(void) 36void __init corenet_ds_pic_init(void)
37{ 37{
38 struct mpic *mpic; 38 struct mpic *mpic;
39 struct device_node *np = NULL;
40 unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN | 39 unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
41 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU; 40 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
42 41
43 np = of_find_node_by_type(np, "open-pic");
44
45 if (np == NULL) {
46 printk(KERN_ERR "Could not find open-pic node\n");
47 return;
48 }
49
50 if (ppc_md.get_irq == mpic_get_coreint_irq) 42 if (ppc_md.get_irq == mpic_get_coreint_irq)
51 flags |= MPIC_ENABLE_COREINT; 43 flags |= MPIC_ENABLE_COREINT;
52 44
53 mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC "); 45 mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
54 BUG_ON(mpic == NULL); 46 BUG_ON(mpic == NULL);
55 47
56 mpic_init(mpic); 48 mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index 3403b0e0143b..1620fa87cd96 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -57,22 +57,10 @@ static void machine_restart(char *cmd)
57 57
58static void __init ksi8560_pic_init(void) 58static void __init ksi8560_pic_init(void)
59{ 59{
60 struct mpic *mpic; 60 struct mpic *mpic = mpic_alloc(NULL, 0,
61 struct device_node *np;
62
63 np = of_find_node_by_type(NULL, "open-pic");
64
65 if (np == NULL) {
66 printk(KERN_ERR "Could not find open-pic node\n");
67 return;
68 }
69
70 mpic = mpic_alloc(np, 0,
71 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 61 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
72 0, 256, " OpenPIC "); 62 0, 256, " OpenPIC ");
73 BUG_ON(mpic == NULL); 63 BUG_ON(mpic == NULL);
74 of_node_put(np);
75
76 mpic_init(mpic); 64 mpic_init(mpic);
77 65
78 mpc85xx_cpm2_pic_init(); 66 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 5c20b28568b0..07916d6e4999 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -36,22 +36,11 @@
36 36
37void __init mpc8536_ds_pic_init(void) 37void __init mpc8536_ds_pic_init(void)
38{ 38{
39 struct mpic *mpic; 39 struct mpic *mpic = mpic_alloc(NULL, 0,
40 struct device_node *np;
41
42 np = of_find_node_by_type(NULL, "open-pic");
43 if (np == NULL) {
44 printk(KERN_ERR "Could not find open-pic node\n");
45 return;
46 }
47
48 mpic = mpic_alloc(np, 0,
49 MPIC_PRIMARY | MPIC_WANTS_RESET | 40 MPIC_PRIMARY | MPIC_WANTS_RESET |
50 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, 41 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
51 0, 256, " OpenPIC "); 42 0, 256, " OpenPIC ");
52 BUG_ON(mpic == NULL); 43 BUG_ON(mpic == NULL);
53 of_node_put(np);
54
55 mpic_init(mpic); 44 mpic_init(mpic);
56} 45}
57 46
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 4c1e9b67ac53..17c6f06e2d41 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -50,21 +50,10 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
50 50
51static void __init mpc85xx_ads_pic_init(void) 51static void __init mpc85xx_ads_pic_init(void)
52{ 52{
53 struct mpic *mpic; 53 struct mpic *mpic = mpic_alloc(NULL, 0,
54 struct device_node *np = NULL;
55
56 np = of_find_node_by_type(np, "open-pic");
57 if (!np) {
58 printk(KERN_ERR "Could not find open-pic node\n");
59 return;
60 }
61
62 mpic = mpic_alloc(np, 0,
63 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 54 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
64 0, 256, " OpenPIC "); 55 0, 256, " OpenPIC ");
65 BUG_ON(mpic == NULL); 56 BUG_ON(mpic == NULL);
66 of_node_put(np);
67
68 mpic_init(mpic); 57 mpic_init(mpic);
69 58
70 mpc85xx_cpm2_pic_init(); 59 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 62b90c359699..cf209b3df7b9 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -188,23 +188,10 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
188static void __init mpc85xx_cds_pic_init(void) 188static void __init mpc85xx_cds_pic_init(void)
189{ 189{
190 struct mpic *mpic; 190 struct mpic *mpic;
191 struct device_node *np = NULL; 191 mpic = mpic_alloc(NULL, 0,
192
193 np = of_find_node_by_type(np, "open-pic");
194
195 if (np == NULL) {
196 printk(KERN_ERR "Could not find open-pic node\n");
197 return;
198 }
199
200 mpic = mpic_alloc(np, 0,
201 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 192 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
202 0, 256, " OpenPIC "); 193 0, 256, " OpenPIC ");
203 BUG_ON(mpic == NULL); 194 BUG_ON(mpic == NULL);
204
205 /* Return the mpic node */
206 of_node_put(np);
207
208 mpic_init(mpic); 195 mpic_init(mpic);
209} 196}
210 197
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 4fc6b801c552..104a09b9f6d3 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -63,27 +63,21 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
63void __init mpc85xx_ds_pic_init(void) 63void __init mpc85xx_ds_pic_init(void)
64{ 64{
65 struct mpic *mpic; 65 struct mpic *mpic;
66 struct device_node *np;
67#ifdef CONFIG_PPC_I8259 66#ifdef CONFIG_PPC_I8259
67 struct device_node *np;
68 struct device_node *cascade_node = NULL; 68 struct device_node *cascade_node = NULL;
69 int cascade_irq; 69 int cascade_irq;
70#endif 70#endif
71 unsigned long root = of_get_flat_dt_root(); 71 unsigned long root = of_get_flat_dt_root();
72 72
73 np = of_find_node_by_type(NULL, "open-pic");
74 if (np == NULL) {
75 printk(KERN_ERR "Could not find open-pic node\n");
76 return;
77 }
78
79 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) { 73 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
80 mpic = mpic_alloc(np, 0, 74 mpic = mpic_alloc(NULL, 0,
81 MPIC_PRIMARY | 75 MPIC_PRIMARY |
82 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 76 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
83 MPIC_SINGLE_DEST_CPU, 77 MPIC_SINGLE_DEST_CPU,
84 0, 256, " OpenPIC "); 78 0, 256, " OpenPIC ");
85 } else { 79 } else {
86 mpic = mpic_alloc(np, 0, 80 mpic = mpic_alloc(NULL, 0,
87 MPIC_PRIMARY | MPIC_WANTS_RESET | 81 MPIC_PRIMARY | MPIC_WANTS_RESET |
88 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 82 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
89 MPIC_SINGLE_DEST_CPU, 83 MPIC_SINGLE_DEST_CPU,
@@ -91,8 +85,6 @@ void __init mpc85xx_ds_pic_init(void)
91 } 85 }
92 86
93 BUG_ON(mpic == NULL); 87 BUG_ON(mpic == NULL);
94 of_node_put(np);
95
96 mpic_init(mpic); 88 mpic_init(mpic);
97 89
98#ifdef CONFIG_PPC_I8259 90#ifdef CONFIG_PPC_I8259
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 74b6da2e0876..4e5431ad9d13 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -434,19 +434,11 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
434 434
435static void __init mpc85xx_mds_pic_init(void) 435static void __init mpc85xx_mds_pic_init(void)
436{ 436{
437 struct mpic *mpic; 437 struct mpic *mpic = mpic_alloc(NULL, 0,
438 struct device_node *np = NULL;
439
440 np = of_find_node_by_type(NULL, "open-pic");
441 if (!np)
442 return;
443
444 mpic = mpic_alloc(np, 0,
445 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN | 438 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
446 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU, 439 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
447 0, 256, " OpenPIC "); 440 0, 256, " OpenPIC ");
448 BUG_ON(mpic == NULL); 441 BUG_ON(mpic == NULL);
449 of_node_put(np);
450 442
451 mpic_init(mpic); 443 mpic_init(mpic);
452 mpc85xx_mds_qeic_init(); 444 mpc85xx_mds_qeic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 2b299eba3670..a68d92271c44 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -45,23 +45,16 @@
45void __init mpc85xx_rdb_pic_init(void) 45void __init mpc85xx_rdb_pic_init(void)
46{ 46{
47 struct mpic *mpic; 47 struct mpic *mpic;
48 struct device_node *np;
49 unsigned long root = of_get_flat_dt_root(); 48 unsigned long root = of_get_flat_dt_root();
50 49
51 np = of_find_node_by_type(NULL, "open-pic");
52 if (np == NULL) {
53 printk(KERN_ERR "Could not find open-pic node\n");
54 return;
55 }
56
57 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) { 50 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
58 mpic = mpic_alloc(np, 0, 51 mpic = mpic_alloc(NULL, 0,
59 MPIC_PRIMARY | 52 MPIC_PRIMARY |
60 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 53 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
61 MPIC_SINGLE_DEST_CPU, 54 MPIC_SINGLE_DEST_CPU,
62 0, 256, " OpenPIC "); 55 0, 256, " OpenPIC ");
63 } else { 56 } else {
64 mpic = mpic_alloc(np, 0, 57 mpic = mpic_alloc(NULL, 0,
65 MPIC_PRIMARY | MPIC_WANTS_RESET | 58 MPIC_PRIMARY | MPIC_WANTS_RESET |
66 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 59 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
67 MPIC_SINGLE_DEST_CPU, 60 MPIC_SINGLE_DEST_CPU,
@@ -69,10 +62,7 @@ void __init mpc85xx_rdb_pic_init(void)
69 } 62 }
70 63
71 BUG_ON(mpic == NULL); 64 BUG_ON(mpic == NULL);
72 of_node_put(np);
73
74 mpic_init(mpic); 65 mpic_init(mpic);
75
76} 66}
77 67
78/* 68/*
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index dff49e83ba6b..25f7375e092f 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -32,16 +32,8 @@
32 32
33void __init p1010_rdb_pic_init(void) 33void __init p1010_rdb_pic_init(void)
34{ 34{
35 struct mpic *mpic; 35 struct mpic *mpic = mpic_alloc(NULL, 0,
36 struct device_node *np; 36 MPIC_PRIMARY | MPIC_WANTS_RESET |
37
38 np = of_find_node_by_type(NULL, "open-pic");
39 if (np == NULL) {
40 printk(KERN_ERR "Could not find open-pic node\n");
41 return;
42 }
43
44 mpic = mpic_alloc(np, 0, MPIC_PRIMARY | MPIC_WANTS_RESET |
45 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU, 37 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
46 0, 256, " OpenPIC "); 38 0, 256, " OpenPIC ");
47 39
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 6d684c2979af..6af5502b0898 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -241,24 +241,12 @@ p1022ds_valid_monitor_port(enum fsl_diu_monitor_port port)
241 241
242void __init p1022_ds_pic_init(void) 242void __init p1022_ds_pic_init(void)
243{ 243{
244 struct mpic *mpic; 244 struct mpic *mpic = mpic_alloc(NULL, 0,
245 struct device_node *np;
246
247 np = of_find_node_by_type(NULL, "open-pic");
248 if (!np) {
249 pr_err("Could not find open-pic node\n");
250 return;
251 }
252
253 mpic = mpic_alloc(np, 0,
254 MPIC_PRIMARY | MPIC_WANTS_RESET | 245 MPIC_PRIMARY | MPIC_WANTS_RESET |
255 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 246 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
256 MPIC_SINGLE_DEST_CPU, 247 MPIC_SINGLE_DEST_CPU,
257 0, 256, " OpenPIC "); 248 0, 256, " OpenPIC ");
258
259 BUG_ON(mpic == NULL); 249 BUG_ON(mpic == NULL);
260 of_node_put(np);
261
262 mpic_init(mpic); 250 mpic_init(mpic);
263} 251}
264 252
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index df7ccf688218..b3c78fe07110 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -93,16 +93,7 @@ machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
93 93
94static void __init mpc85xx_rds_pic_init(void) 94static void __init mpc85xx_rds_pic_init(void)
95{ 95{
96 struct mpic *mpic; 96 struct mpic *mpic = mpic_alloc(NULL, 0,
97 struct device_node *np = NULL;
98
99 np = of_find_node_by_type(NULL, "open-pic");
100 if (!np) {
101 printk(KERN_ERR "Could not find open-pic node\n");
102 return;
103 }
104
105 mpic = mpic_alloc(np, 0,
106 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN | 97 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
107 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU, 98 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
108 0, 256, " OpenPIC "); 99 0, 256, " OpenPIC ");
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 5e16025a755e..38d6945382b8 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -54,24 +54,10 @@ static int sbc_rev;
54 54
55static void __init sbc8548_pic_init(void) 55static void __init sbc8548_pic_init(void)
56{ 56{
57 struct mpic *mpic; 57 struct mpic *mpic = mpic_alloc(NULL, 0,
58 struct device_node *np = NULL;
59
60 np = of_find_node_by_type(np, "open-pic");
61
62 if (np == NULL) {
63 printk(KERN_ERR "Could not find open-pic node\n");
64 return;
65 }
66
67 mpic = mpic_alloc(np, 0,
68 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 58 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
69 0, 256, " OpenPIC "); 59 0, 256, " OpenPIC ");
70 BUG_ON(mpic == NULL); 60 BUG_ON(mpic == NULL);
71
72 /* Return the mpic node */
73 of_node_put(np);
74
75 mpic_init(mpic); 61 mpic_init(mpic);
76} 62}
77 63
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 97f00dec0d93..7e6d7e5b8a41 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -41,21 +41,10 @@
41 41
42static void __init sbc8560_pic_init(void) 42static void __init sbc8560_pic_init(void)
43{ 43{
44 struct mpic *mpic; 44 struct mpic *mpic = mpic_alloc(NULL, 0,
45 struct device_node *np = NULL;
46
47 np = of_find_node_by_type(np, "open-pic");
48 if (!np) {
49 printk(KERN_ERR "Could not find open-pic node\n");
50 return;
51 }
52
53 mpic = mpic_alloc(np, 0,
54 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 45 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
55 0, 256, " OpenPIC "); 46 0, 256, " OpenPIC ");
56 BUG_ON(mpic == NULL); 47 BUG_ON(mpic == NULL);
57 of_node_put(np);
58
59 mpic_init(mpic); 48 mpic_init(mpic);
60 49
61 mpc85xx_cpm2_pic_init(); 50 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index e87e75cdb940..8175f0a5e5f0 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -46,21 +46,12 @@
46 46
47static void __init socrates_pic_init(void) 47static void __init socrates_pic_init(void)
48{ 48{
49 struct mpic *mpic;
50 struct device_node *np; 49 struct device_node *np;
51 50
52 np = of_find_node_by_type(NULL, "open-pic"); 51 struct mpic *mpic = mpic_alloc(NULL, 0,
53 if (!np) {
54 printk(KERN_ERR "Could not find open-pic node\n");
55 return;
56 }
57
58 mpic = mpic_alloc(np, 0,
59 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 52 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
60 0, 256, " OpenPIC "); 53 0, 256, " OpenPIC ");
61 BUG_ON(mpic == NULL); 54 BUG_ON(mpic == NULL);
62 of_node_put(np);
63
64 mpic_init(mpic); 55 mpic_init(mpic);
65 56
66 np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic"); 57 np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 060d51480758..8ca1e61488df 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -48,21 +48,10 @@
48 48
49static void __init stx_gp3_pic_init(void) 49static void __init stx_gp3_pic_init(void)
50{ 50{
51 struct mpic *mpic; 51 struct mpic *mpic = mpic_alloc(NULL, 0,
52 struct device_node *np;
53
54 np = of_find_node_by_type(NULL, "open-pic");
55 if (!np) {
56 printk(KERN_ERR "Could not find open-pic node\n");
57 return;
58 }
59
60 mpic = mpic_alloc(np, 0,
61 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 52 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
62 0, 256, " OpenPIC "); 53 0, 256, " OpenPIC ");
63 BUG_ON(mpic == NULL); 54 BUG_ON(mpic == NULL);
64 of_node_put(np);
65
66 mpic_init(mpic); 55 mpic_init(mpic);
67 56
68 mpc85xx_cpm2_pic_init(); 57 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index a46b9fc66205..6e7a8351e8f9 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -46,21 +46,10 @@
46 46
47static void __init tqm85xx_pic_init(void) 47static void __init tqm85xx_pic_init(void)
48{ 48{
49 struct mpic *mpic; 49 struct mpic *mpic = mpic_alloc(NULL, 0,
50 struct device_node *np;
51
52 np = of_find_node_by_type(NULL, "open-pic");
53 if (!np) {
54 printk(KERN_ERR "Could not find open-pic node\n");
55 return;
56 }
57
58 mpic = mpic_alloc(np, 0,
59 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 50 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
60 0, 256, " OpenPIC "); 51 0, 256, " OpenPIC ");
61 BUG_ON(mpic == NULL); 52 BUG_ON(mpic == NULL);
62 of_node_put(np);
63
64 mpic_init(mpic); 53 mpic_init(mpic);
65 54
66 mpc85xx_cpm2_pic_init(); 55 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 2be5e4de1882..f94c60868496 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -43,22 +43,11 @@
43 43
44void __init xes_mpc85xx_pic_init(void) 44void __init xes_mpc85xx_pic_init(void)
45{ 45{
46 struct mpic *mpic; 46 struct mpic *mpic = mpic_alloc(NULL, 0,
47 struct device_node *np;
48
49 np = of_find_node_by_type(NULL, "open-pic");
50 if (np == NULL) {
51 printk(KERN_ERR "Could not find open-pic node\n");
52 return;
53 }
54
55 mpic = mpic_alloc(np, 0,
56 MPIC_PRIMARY | MPIC_WANTS_RESET | 47 MPIC_PRIMARY | MPIC_WANTS_RESET |
57 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, 48 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
58 0, 256, " OpenPIC "); 49 0, 256, " OpenPIC ");
59 BUG_ON(mpic == NULL); 50 BUG_ON(mpic == NULL);
60 of_node_put(np);
61
62 mpic_init(mpic); 51 mpic_init(mpic);
63} 52}
64 53
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index f85c8f0aa966..ed85b3c8ed18 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -31,24 +31,17 @@ static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
31 31
32void __init mpc86xx_init_irq(void) 32void __init mpc86xx_init_irq(void)
33{ 33{
34 struct mpic *mpic;
35 struct device_node *np;
36#ifdef CONFIG_PPC_I8259 34#ifdef CONFIG_PPC_I8259
35 struct device_node *np;
37 struct device_node *cascade_node = NULL; 36 struct device_node *cascade_node = NULL;
38 int cascade_irq; 37 int cascade_irq;
39#endif 38#endif
40 39
41 /* Determine PIC address. */ 40 struct mpic *mpic = mpic_alloc(NULL, 0,
42 np = of_find_node_by_type(NULL, "open-pic");
43 if (np == NULL)
44 return;
45
46 mpic = mpic_alloc(np, 0,
47 MPIC_PRIMARY | MPIC_WANTS_RESET | 41 MPIC_PRIMARY | MPIC_WANTS_RESET |
48 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 42 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
49 MPIC_SINGLE_DEST_CPU, 43 MPIC_SINGLE_DEST_CPU,
50 0, 256, " MPIC "); 44 0, 256, " MPIC ");
51 of_node_put(np);
52 BUG_ON(mpic == NULL); 45 BUG_ON(mpic == NULL);
53 46
54 mpic_init(mpic); 47 mpic_init(mpic);
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index d4fb41e29c35..5ed00a70a864 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -148,20 +148,13 @@ static void __init holly_setup_arch(void)
148static void __init holly_init_IRQ(void) 148static void __init holly_init_IRQ(void)
149{ 149{
150 struct mpic *mpic; 150 struct mpic *mpic;
151 struct device_node *tsi_pic;
152#ifdef CONFIG_PCI 151#ifdef CONFIG_PCI
153 unsigned int cascade_pci_irq; 152 unsigned int cascade_pci_irq;
154 struct device_node *tsi_pci; 153 struct device_node *tsi_pci;
155 struct device_node *cascade_node = NULL; 154 struct device_node *cascade_node = NULL;
156#endif 155#endif
157 156
158 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 157 mpic = mpic_alloc(NULL, 0,
159 if (!tsi_pic) {
160 printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
161 return;
162 }
163
164 mpic = mpic_alloc(tsi_pic, 0,
165 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET | 158 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
166 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108, 159 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
167 24, 160 24,
@@ -195,7 +188,6 @@ static void __init holly_init_IRQ(void)
195#endif 188#endif
196 /* Configure MPIC outputs to CPU0 */ 189 /* Configure MPIC outputs to CPU0 */
197 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0); 190 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
198 of_node_put(tsi_pic);
199} 191}
200 192
201void holly_show_cpuinfo(struct seq_file *m) 193void holly_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 72b36850c5e3..502ff60db968 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -81,13 +81,9 @@ static void __init linkstation_setup_arch(void)
81static void __init linkstation_init_IRQ(void) 81static void __init linkstation_init_IRQ(void)
82{ 82{
83 struct mpic *mpic; 83 struct mpic *mpic;
84 struct device_node *dnp;
85 84
86 dnp = of_find_node_by_type(NULL, "open-pic"); 85 mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
87 if (dnp == NULL) 86 4, 32, " EPIC ");
88 return;
89
90 mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
91 BUG_ON(mpic == NULL); 87 BUG_ON(mpic == NULL);
92 88
93 /* PCI IRQs */ 89 /* PCI IRQs */
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index c8ce204abd2d..e0f112790397 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -102,20 +102,13 @@ static void __init mpc7448_hpc2_setup_arch(void)
102static void __init mpc7448_hpc2_init_IRQ(void) 102static void __init mpc7448_hpc2_init_IRQ(void)
103{ 103{
104 struct mpic *mpic; 104 struct mpic *mpic;
105 struct device_node *tsi_pic;
106#ifdef CONFIG_PCI 105#ifdef CONFIG_PCI
107 unsigned int cascade_pci_irq; 106 unsigned int cascade_pci_irq;
108 struct device_node *tsi_pci; 107 struct device_node *tsi_pci;
109 struct device_node *cascade_node = NULL; 108 struct device_node *cascade_node = NULL;
110#endif 109#endif
111 110
112 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 111 mpic = mpic_alloc(NULL, 0,
113 if (!tsi_pic) {
114 printk("%s: No tsi108 PIC found !\n", __func__);
115 return;
116 }
117
118 mpic = mpic_alloc(tsi_pic, 0,
119 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET | 112 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
120 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108, 113 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
121 24, 114 24,
@@ -149,7 +142,6 @@ static void __init mpc7448_hpc2_init_IRQ(void)
149#endif 142#endif
150 /* Configure MPIC outputs to CPU0 */ 143 /* Configure MPIC outputs to CPU0 */
151 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0); 144 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
152 of_node_put(tsi_pic);
153} 145}
154 146
155void mpc7448_hpc2_show_cpuinfo(struct seq_file *m) 147void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index 084f0fc706b7..9bd15dfea579 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -83,17 +83,9 @@ static void __init storcenter_setup_arch(void)
83static void __init storcenter_init_IRQ(void) 83static void __init storcenter_init_IRQ(void)
84{ 84{
85 struct mpic *mpic; 85 struct mpic *mpic;
86 struct device_node *dnp;
87 86
88 dnp = of_find_node_by_type(NULL, "open-pic"); 87 mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
89 if (dnp == NULL)
90 return;
91
92 mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
93 16, 32, " OpenPIC "); 88 16, 32, " OpenPIC ");
94
95 of_node_put(dnp);
96
97 BUG_ON(mpic == NULL); 89 BUG_ON(mpic == NULL);
98 90
99 /* 91 /*
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index ef721c30f479..bb72a6266480 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1143,8 +1143,24 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1143 const char *vers; 1143 const char *vers;
1144 const u32 *psrc; 1144 const u32 *psrc;
1145 1145
1146 /* This code assumes that a non-NULL device node is passed in */ 1146 /* Default MPIC search parameters */
1147 BUG_ON(!node); 1147 static const struct of_device_id __initconst mpic_device_id[] = {
1148 { .type = "open-pic", },
1149 { .compatible = "open-pic", },
1150 {},
1151 };
1152
1153 /*
1154 * If we were not passed a device-tree node, then perform the default
1155 * search for standardized a standardized OpenPIC.
1156 */
1157 if (node) {
1158 node = of_node_get(node);
1159 } else {
1160 node = of_find_matching_node(NULL, mpic_device_id);
1161 if (!node)
1162 return NULL;
1163 }
1148 1164
1149 /* Pick the physical address from the device tree if unspecified */ 1165 /* Pick the physical address from the device tree if unspecified */
1150 if (!phys_addr) { 1166 if (!phys_addr) {
@@ -1154,14 +1170,14 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1154 } else { 1170 } else {
1155 struct resource r; 1171 struct resource r;
1156 if (of_address_to_resource(node, 0, &r)) 1172 if (of_address_to_resource(node, 0, &r))
1157 return NULL; 1173 goto err_of_node_put;
1158 phys_addr = r.start; 1174 phys_addr = r.start;
1159 } 1175 }
1160 } 1176 }
1161 1177
1162 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); 1178 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
1163 if (mpic == NULL) 1179 if (mpic == NULL)
1164 return NULL; 1180 goto err_of_node_put;
1165 1181
1166 mpic->name = name; 1182 mpic->name = name;
1167 mpic->paddr = phys_addr; 1183 mpic->paddr = phys_addr;
@@ -1325,6 +1341,11 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1325 isu_size ? isu_size : mpic->num_sources, 1341 isu_size ? isu_size : mpic->num_sources,
1326 &mpic_host_ops, 1342 &mpic_host_ops,
1327 flags & MPIC_LARGE_VECTORS ? 2048 : 256); 1343 flags & MPIC_LARGE_VECTORS ? 2048 : 256);
1344
1345 /*
1346 * FIXME: The code leaks the MPIC object and mappings here; this
1347 * is very unlikely to fail but it ought to be fixed anyways.
1348 */
1328 if (mpic->irqhost == NULL) 1349 if (mpic->irqhost == NULL)
1329 return NULL; 1350 return NULL;
1330 1351
@@ -1359,7 +1380,12 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1359 irq_set_default_host(mpic->irqhost); 1380 irq_set_default_host(mpic->irqhost);
1360 } 1381 }
1361 1382
1383 of_node_put(node);
1362 return mpic; 1384 return mpic;
1385
1386err_of_node_put:
1387 of_node_put(node);
1388 return NULL;
1363} 1389}
1364 1390
1365void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, 1391void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,