powerpc/mpic: Search for open-pic device-tree node if NULL
authorKyle Moffett <Kyle.D.Moffett@boeing.com>
Fri, 2 Dec 2011 06:28:02 +0000 (06:28 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Dec 2011 02:43:07 +0000 (13:43 +1100)
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>
23 files changed:
arch/powerpc/platforms/85xx/corenet_ds.c
arch/powerpc/platforms/85xx/ksi8560.c
arch/powerpc/platforms/85xx/mpc8536_ds.c
arch/powerpc/platforms/85xx/mpc85xx_ads.c
arch/powerpc/platforms/85xx/mpc85xx_cds.c
arch/powerpc/platforms/85xx/mpc85xx_ds.c
arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/powerpc/platforms/85xx/mpc85xx_rdb.c
arch/powerpc/platforms/85xx/p1010rdb.c
arch/powerpc/platforms/85xx/p1022_ds.c
arch/powerpc/platforms/85xx/p1023_rds.c
arch/powerpc/platforms/85xx/sbc8548.c
arch/powerpc/platforms/85xx/sbc8560.c
arch/powerpc/platforms/85xx/socrates.c
arch/powerpc/platforms/85xx/stx_gp3.c
arch/powerpc/platforms/85xx/tqm85xx.c
arch/powerpc/platforms/85xx/xes_mpc85xx.c
arch/powerpc/platforms/86xx/pic.c
arch/powerpc/platforms/embedded6xx/holly.c
arch/powerpc/platforms/embedded6xx/linkstation.c
arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
arch/powerpc/platforms/embedded6xx/storcenter.c
arch/powerpc/sysdev/mpic.c

index 5b1c577199bf48a984e0d88081254598eee50d41..cfa4bada7eb28e3364f728a696e8ae34fd730ce6 100644 (file)
 void __init corenet_ds_pic_init(void)
 {
        struct mpic *mpic;
-       struct device_node *np = NULL;
        unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
                                MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
 
-       np = of_find_node_by_type(np, "open-pic");
-
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
        if (ppc_md.get_irq == mpic_get_coreint_irq)
                flags |= MPIC_ENABLE_COREINT;
 
-       mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC  ");
+       mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
 
        mpic_init(mpic);
index 3403b0e0143b89d544d101719e689f6640669253..1620fa87cd9674ad93573f42bc647b985df62a2f 100644 (file)
@@ -57,22 +57,10 @@ static void machine_restart(char *cmd)
 
 static void __init ksi8560_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        mpc85xx_cpm2_pic_init();
index 5c20b28568b051efbe58dc15f2cbf1ee8ef25da5..07916d6e49998d21b7bca9dd8359e32852634015 100644 (file)
 
 void __init mpc8536_ds_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                          MPIC_PRIMARY | MPIC_WANTS_RESET |
                          MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 }
 
index 4c1e9b67ac531e3f8bdea36f4bd5725a97a95ed7..17c6f06e2d415921e2eb962c0708a4bab519710f 100644 (file)
@@ -50,21 +50,10 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 
 static void __init mpc85xx_ads_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(np, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        mpc85xx_cpm2_pic_init();
index 62b90c3596992bef1996dcf4ecce9e6295e1ec28..cf209b3df7b939f370a97aea986b2d60051056b5 100644 (file)
@@ -188,23 +188,10 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
 static void __init mpc85xx_cds_pic_init(void)
 {
        struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(np, "open-pic");
-
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-
-       /* Return the mpic node */
-       of_node_put(np);
-
        mpic_init(mpic);
 }
 
index 4fc6b801c552b3ba62544ab2f05bc7f6c6e2abf2..104a09b9f6d35623b93b289b53aa8604dfdfe5e2 100644 (file)
@@ -63,27 +63,21 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 void __init mpc85xx_ds_pic_init(void)
 {
        struct mpic *mpic;
-       struct device_node *np;
 #ifdef CONFIG_PPC_I8259
+       struct device_node *np;
        struct device_node *cascade_node = NULL;
        int cascade_irq;
 #endif
        unsigned long root = of_get_flat_dt_root();
 
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
        if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
-               mpic = mpic_alloc(np, 0,
+               mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY |
                        MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                        MPIC_SINGLE_DEST_CPU,
                        0, 256, " OpenPIC  ");
        } else {
-               mpic = mpic_alloc(np, 0,
+               mpic = mpic_alloc(NULL, 0,
                          MPIC_PRIMARY | MPIC_WANTS_RESET |
                          MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                          MPIC_SINGLE_DEST_CPU,
@@ -91,8 +85,6 @@ void __init mpc85xx_ds_pic_init(void)
        }
 
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
 #ifdef CONFIG_PPC_I8259
index 74b6da2e0876d8143ff0b754bd8ee3db664231a2..4e5431ad9d1368b1eecec3538a56ee7996d357f3 100644 (file)
@@ -434,19 +434,11 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 
 static void __init mpc85xx_mds_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np)
-               return;
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
                        MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
 
        mpic_init(mpic);
        mpc85xx_mds_qeic_init();
index 2b299eba3670b408a73e18e2ac48402a03fa76ca..a68d92271c443c5bf67a701c9fc4cf0bc16d4534 100644 (file)
 void __init mpc85xx_rdb_pic_init(void)
 {
        struct mpic *mpic;
-       struct device_node *np;
        unsigned long root = of_get_flat_dt_root();
 
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
        if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
-               mpic = mpic_alloc(np, 0,
+               mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY |
                        MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                        MPIC_SINGLE_DEST_CPU,
                        0, 256, " OpenPIC  ");
        } else {
-               mpic = mpic_alloc(np, 0,
+               mpic = mpic_alloc(NULL, 0,
                  MPIC_PRIMARY | MPIC_WANTS_RESET |
                  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                  MPIC_SINGLE_DEST_CPU,
@@ -69,10 +62,7 @@ void __init mpc85xx_rdb_pic_init(void)
        }
 
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
-
 }
 
 /*
index dff49e83ba6b68dce3af99e1ed1aa996228305b0..25f7375e092f54c8aac3f8d41ec9172e30cb8b90 100644 (file)
 
 void __init p1010_rdb_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0, MPIC_PRIMARY | MPIC_WANTS_RESET |
+       struct mpic *mpic = mpic_alloc(NULL, 0,
+         MPIC_PRIMARY | MPIC_WANTS_RESET |
          MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
          0, 256, " OpenPIC  ");
 
index 6d684c2979af2a860abb98118ca83538eafa4799..6af5502b08983ee5a9205879672558c947a8c767 100644 (file)
@@ -241,24 +241,12 @@ p1022ds_valid_monitor_port(enum fsl_diu_monitor_port port)
 
 void __init p1022_ds_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np) {
-               pr_err("Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                MPIC_PRIMARY | MPIC_WANTS_RESET |
                MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                MPIC_SINGLE_DEST_CPU,
                0, 256, " OpenPIC  ");
-
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 }
 
index df7ccf688218bb069ff661ccdbea8f47b952ca1a..b3c78fe07110de66320a6b861dea57b0259bf0c9 100644 (file)
@@ -93,16 +93,7 @@ machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
 
 static void __init mpc85xx_rds_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
                MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
                0, 256, " OpenPIC  ");
index 5e16025a755e8b152fa1f831d81da33f478fd124..38d6945382b82759f6a51e9cff96dfbffdbe4a59 100644 (file)
@@ -54,24 +54,10 @@ static int sbc_rev;
 
 static void __init sbc8548_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(np, "open-pic");
-
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-
-       /* Return the mpic node */
-       of_node_put(np);
-
        mpic_init(mpic);
 }
 
index 97f00dec0d93610ae7ab21351abe7ec1ecb118f9..7e6d7e5b8a412a16280e1919742f5adc2127c9bd 100644 (file)
 
 static void __init sbc8560_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np = NULL;
-
-       np = of_find_node_by_type(np, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        mpc85xx_cpm2_pic_init();
index e87e75cdb94021d6cf42c157b5f07bcb4a2c73f1..8175f0a5e5f097818c8fad4753eb65895630dc3d 100644 (file)
 
 static void __init socrates_pic_init(void)
 {
-       struct mpic *mpic;
        struct device_node *np;
 
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
index 060d51480758b27198a6cf5e2fb8fd48f198d9b6..8ca1e61488df269a274916ce349adfbb34ab73bb 100644 (file)
 
 static void __init stx_gp3_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        mpc85xx_cpm2_pic_init();
index a46b9fc662050fb8122f010ba5cb1fd402482473..6e7a8351e8f94f61f24cd96a7b8ddfc74cefc8f9 100644 (file)
 
 static void __init tqm85xx_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (!np) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 
        mpc85xx_cpm2_pic_init();
index 2be5e4de1882bef76e9d2789de373a58a9d469fe..f94c60868496bf01811fa7507b40f84ea6f39040 100644 (file)
 
 void __init xes_mpc85xx_pic_init(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "Could not find open-pic node\n");
-               return;
-       }
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                          MPIC_PRIMARY | MPIC_WANTS_RESET |
                          MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
                        0, 256, " OpenPIC  ");
        BUG_ON(mpic == NULL);
-       of_node_put(np);
-
        mpic_init(mpic);
 }
 
index f85c8f0aa96614c99a4d1ab8c716eda8c7606cb0..ed85b3c8ed186d4c490be9b26fe3732729b86095 100644 (file)
@@ -31,24 +31,17 @@ static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 
 void __init mpc86xx_init_irq(void)
 {
-       struct mpic *mpic;
-       struct device_node *np;
 #ifdef CONFIG_PPC_I8259
+       struct device_node *np;
        struct device_node *cascade_node = NULL;
        int cascade_irq;
 #endif
 
-       /* Determine PIC address. */
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL)
-               return;
-
-       mpic = mpic_alloc(np, 0,
+       struct mpic *mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_WANTS_RESET |
                        MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
                        MPIC_SINGLE_DEST_CPU,
                        0, 256, " MPIC     ");
-       of_node_put(np);
        BUG_ON(mpic == NULL);
 
        mpic_init(mpic);
index d4fb41e29c351574366d77e19aa7a596c499eb3e..5ed00a70a864208af26f1d0ca1a52bdb18f9297b 100644 (file)
@@ -148,20 +148,13 @@ static void __init holly_setup_arch(void)
 static void __init holly_init_IRQ(void)
 {
        struct mpic *mpic;
-       struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
        unsigned int cascade_pci_irq;
        struct device_node *tsi_pci;
        struct device_node *cascade_node = NULL;
 #endif
 
-       tsi_pic = of_find_node_by_type(NULL, "open-pic");
-       if (!tsi_pic) {
-               printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
-               return;
-       }
-
-       mpic = mpic_alloc(tsi_pic, 0,
+       mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
                        MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
                        24,
@@ -195,7 +188,6 @@ static void __init holly_init_IRQ(void)
 #endif
        /* Configure MPIC outputs to CPU0 */
        tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-       of_node_put(tsi_pic);
 }
 
 void holly_show_cpuinfo(struct seq_file *m)
index 72b36850c5e37bad1f3672f29d91f0fce29c72f1..502ff60db96834bf4a6fec7b823637ac045aedb9 100644 (file)
@@ -81,13 +81,9 @@ static void __init linkstation_setup_arch(void)
 static void __init linkstation_init_IRQ(void)
 {
        struct mpic *mpic;
-       struct device_node *dnp;
 
-       dnp = of_find_node_by_type(NULL, "open-pic");
-       if (dnp == NULL)
-               return;
-
-       mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC     ");
+       mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+                       4, 32, " EPIC     ");
        BUG_ON(mpic == NULL);
 
        /* PCI IRQs */
index c8ce204abd2d564261f2294a7115fe2f36240a33..e0f112790397f45d19ecb307727e8ebc7591f806 100644 (file)
@@ -102,20 +102,13 @@ static void __init mpc7448_hpc2_setup_arch(void)
 static void __init mpc7448_hpc2_init_IRQ(void)
 {
        struct mpic *mpic;
-       struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
        unsigned int cascade_pci_irq;
        struct device_node *tsi_pci;
        struct device_node *cascade_node = NULL;
 #endif
 
-       tsi_pic = of_find_node_by_type(NULL, "open-pic");
-       if (!tsi_pic) {
-               printk("%s: No tsi108 PIC found !\n", __func__);
-               return;
-       }
-
-       mpic = mpic_alloc(tsi_pic, 0,
+       mpic = mpic_alloc(NULL, 0,
                        MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
                        MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
                        24,
@@ -149,7 +142,6 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
        /* Configure MPIC outputs to CPU0 */
        tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-       of_node_put(tsi_pic);
 }
 
 void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
index 084f0fc706b71aa40f158827db1ab3d9b14e0909..9bd15dfea57977760a38b8f275f789947e7c1626 100644 (file)
@@ -83,17 +83,9 @@ static void __init storcenter_setup_arch(void)
 static void __init storcenter_init_IRQ(void)
 {
        struct mpic *mpic;
-       struct device_node *dnp;
 
-       dnp = of_find_node_by_type(NULL, "open-pic");
-       if (dnp == NULL)
-               return;
-
-       mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+       mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
                        16, 32, " OpenPIC  ");
-
-       of_node_put(dnp);
-
        BUG_ON(mpic == NULL);
 
        /*
index ef721c30f4799f701d2ae2be6806c806584bb5e0..bb72a6266480718c4f9c401c20123310f3c459e9 100644 (file)
@@ -1143,8 +1143,24 @@ struct mpic * __init mpic_alloc(struct device_node *node,
        const char *vers;
        const u32 *psrc;
 
-       /* This code assumes that a non-NULL device node is passed in */
-       BUG_ON(!node);
+       /* Default MPIC search parameters */
+       static const struct of_device_id __initconst mpic_device_id[] = {
+               { .type       = "open-pic", },
+               { .compatible = "open-pic", },
+               {},
+       };
+
+       /*
+        * If we were not passed a device-tree node, then perform the default
+        * search for standardized a standardized OpenPIC.
+        */
+       if (node) {
+               node = of_node_get(node);
+       } else {
+               node = of_find_matching_node(NULL, mpic_device_id);
+               if (!node)
+                       return NULL;
+       }
 
        /* Pick the physical address from the device tree if unspecified */
        if (!phys_addr) {
@@ -1154,14 +1170,14 @@ struct mpic * __init mpic_alloc(struct device_node *node,
                } else {
                        struct resource r;
                        if (of_address_to_resource(node, 0, &r))
-                               return NULL;
+                               goto err_of_node_put;
                        phys_addr = r.start;
                }
        }
 
        mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
        if (mpic == NULL)
-               return NULL;
+               goto err_of_node_put;
 
        mpic->name = name;
        mpic->paddr = phys_addr;
@@ -1325,6 +1341,11 @@ struct mpic * __init mpic_alloc(struct device_node *node,
                                       isu_size ? isu_size : mpic->num_sources,
                                       &mpic_host_ops,
                                       flags & MPIC_LARGE_VECTORS ? 2048 : 256);
+
+       /*
+        * FIXME: The code leaks the MPIC object and mappings here; this
+        * is very unlikely to fail but it ought to be fixed anyways.
+        */
        if (mpic->irqhost == NULL)
                return NULL;
 
@@ -1359,7 +1380,12 @@ struct mpic * __init mpic_alloc(struct device_node *node,
                irq_set_default_host(mpic->irqhost);
        }
 
+       of_node_put(node);
        return mpic;
+
+err_of_node_put:
+       of_node_put(node);
+       return NULL;
 }
 
 void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,