powerpc: Fix irq_alloc_host() reference counting and callers
authorMichael Ellerman <michael@ellerman.id.au>
Mon, 26 May 2008 02:12:32 +0000 (12:12 +1000)
committerPaul Mackerras <paulus@samba.org>
Mon, 9 Jun 2008 03:51:16 +0000 (13:51 +1000)
When I changed irq_alloc_host() to take an of_node
(52964f87c64e6c6ea671b5bf3030fb1494090a48: "Add an optional
device_node pointer to the irq_host"), I botched the reference
counting semantics.

Stephen pointed out that it's irq_alloc_host()'s business if
it needs to take an additional reference to the device_node,
the caller shouldn't need to care.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/irq.c
arch/powerpc/platforms/cell/axon_msi.c
arch/powerpc/platforms/cell/spider-pic.c
arch/powerpc/sysdev/cpm1.c
arch/powerpc/sysdev/cpm2_pic.c
arch/powerpc/sysdev/i8259.c
arch/powerpc/sysdev/ipic.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/qe_lib/qe_ic.c
arch/powerpc/sysdev/tsi108_pci.c
arch/powerpc/sysdev/uic.c

index b5199752ac60369b28a948f4fb2d55ba76fb8919..e9238556ae50dd1909442c898d607b6879a21094 100644 (file)
@@ -498,7 +498,7 @@ struct irq_host *irq_alloc_host(struct device_node *of_node,
        host->revmap_type = revmap_type;
        host->inval_irq = inval_irq;
        host->ops = ops;
-       host->of_node = of_node;
+       host->of_node = of_node_get(of_node);
 
        if (host->ops->match == NULL)
                host->ops->match = default_irq_host_match;
index b43defb9918cd68336613f060cda39ff6353264e..896548ba1ca12f4eb07c7984a8b1f7d01d232a4f 100644 (file)
@@ -365,7 +365,7 @@ static int axon_msi_probe(struct of_device *device,
                goto out_free_fifo;
        }
 
-       msic->irq_host = irq_alloc_host(of_node_get(dn), IRQ_HOST_MAP_NOMAP,
+       msic->irq_host = irq_alloc_host(dn, IRQ_HOST_MAP_NOMAP,
                                        NR_IRQS, &msic_host_ops, 0);
        if (!msic->irq_host) {
                printk(KERN_ERR "axon_msi: couldn't allocate irq_host for %s\n",
index 3f4b4aef756d8821139c1def2b7b666041a516ad..4e5655624ae877f1e0c8de8eaac716fba9db4f21 100644 (file)
@@ -300,7 +300,7 @@ static void __init spider_init_one(struct device_node *of_node, int chip,
                panic("spider_pic: can't map registers !");
 
        /* Allocate a host */
-       pic->host = irq_alloc_host(of_node_get(of_node), IRQ_HOST_MAP_LINEAR,
+       pic->host = irq_alloc_host(of_node, IRQ_HOST_MAP_LINEAR,
                                   SPIDER_SRC_COUNT, &spider_host_ops,
                                   SPIDER_IRQ_INVALID);
        if (pic->host == NULL)
index 58292a086c164059e5d37a7de347003d436c7230..661df42830b912fc304783ac2b0aea135b9daaa3 100644 (file)
@@ -159,7 +159,7 @@ unsigned int cpm_pic_init(void)
 
        out_be32(&cpic_reg->cpic_cimr, 0);
 
-       cpm_pic_host = irq_alloc_host(of_node_get(np), IRQ_HOST_MAP_LINEAR,
+       cpm_pic_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR,
                                      64, &cpm_pic_host_ops, 64);
        if (cpm_pic_host == NULL) {
                printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n");
index 5fe65b2f8f3a7a2c8d9079940f2eb1fdc79dac4e..b16ca3ed65d25bbee94aaeb82809c6810e60db97 100644 (file)
@@ -266,7 +266,7 @@ void cpm2_pic_init(struct device_node *node)
        out_be32(&cpm2_intctl->ic_scprrl, 0x05309770);
 
        /* create a legacy host */
-       cpm2_pic_host = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
+       cpm2_pic_host = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
                                       64, &cpm2_pic_host_ops, 64);
        if (cpm2_pic_host == NULL) {
                printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n");
index 216c0f5680d25ee0b5411e6dd30ecddfb2311ed5..a96584ab33dda7e9e8140bf1db9bae897364545d 100644 (file)
@@ -276,7 +276,7 @@ void i8259_init(struct device_node *node, unsigned long intack_addr)
        spin_unlock_irqrestore(&i8259_lock, flags);
 
        /* create a legacy host */
-       i8259_host = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LEGACY,
+       i8259_host = irq_alloc_host(node, IRQ_HOST_MAP_LEGACY,
                                    0, &i8259_host_ops, 0);
        if (i8259_host == NULL) {
                printk(KERN_ERR "i8259: failed to allocate irq host !\n");
index f95d10ba3b9c2126cf7c9542526e290ce70c2e28..caba1c0be5a761e975b12392b3839442a92f34dd 100644 (file)
@@ -735,13 +735,11 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
 
        memset(ipic, 0, sizeof(struct ipic));
 
-       ipic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
+       ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
                                       NR_IPIC_INTS,
                                       &ipic_host_ops, 0);
-       if (ipic->irqhost == NULL) {
-               of_node_put(node);
+       if (ipic->irqhost == NULL)
                return NULL;
-       }
 
        ipic->regs = ioremap(res.start, res.end - res.start + 1);
 
index a281341e412954dcffebf823108ac86cc3bd554a..5788a6ab1254608bf989a8b9b3cc48d70d3f12cc 100644 (file)
@@ -1016,13 +1016,11 @@ struct mpic * __init mpic_alloc(struct device_node *node,
        memset(mpic, 0, sizeof(struct mpic));
        mpic->name = name;
 
-       mpic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
+       mpic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
                                       isu_size, &mpic_host_ops,
                                       flags & MPIC_LARGE_VECTORS ? 2048 : 256);
-       if (mpic->irqhost == NULL) {
-               of_node_put(node);
+       if (mpic->irqhost == NULL)
                return NULL;
-       }
 
        mpic->irqhost->host_data = mpic;
        mpic->hc_irq = mpic_irq_chip;
index c11b313f015bffab263f17294ab837cd2923bb3d..63cdf9887f3672dd4e16310b591b91d564de20bd 100644 (file)
@@ -339,12 +339,10 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
 
        memset(qe_ic, 0, sizeof(struct qe_ic));
 
-       qe_ic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
+       qe_ic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
                                        NR_QE_IC_INTS, &qe_ic_host_ops, 0);
-       if (qe_ic->irqhost == NULL) {
-               of_node_put(node);
+       if (qe_ic->irqhost == NULL)
                return;
-       }
 
        qe_ic->regs = ioremap(res.start, res.end - res.start + 1);
 
index ac1a72dc21e576b51a849aa540fad165568481b2..24e1f5a197ae31d3de4377a23e936449072e5e80 100644 (file)
@@ -426,11 +426,10 @@ void __init tsi108_pci_int_init(struct device_node *node)
 {
        DBG("Tsi108_pci_int_init: initializing PCI interrupts\n");
 
-       pci_irq_host = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LEGACY,
+       pci_irq_host = irq_alloc_host(node, IRQ_HOST_MAP_LEGACY,
                                      0, &pci_irq_host_ops, 0);
        if (pci_irq_host == NULL) {
                printk(KERN_ERR "pci_irq_host: failed to allocate irq host !\n");
-               of_node_put(node);
                return;
        }
 
index 625b275c37950296ea93fd0506dcbefca92b2bb8..d35405c5943482c86efea86739099ed8c2f3da1e 100644 (file)
@@ -280,12 +280,10 @@ static struct uic * __init uic_init_one(struct device_node *node)
        }
        uic->dcrbase = *dcrreg;
 
-       uic->irqhost = irq_alloc_host(of_node_get(node), IRQ_HOST_MAP_LINEAR,
+       uic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
                                      NR_UIC_INTS, &uic_host_ops, -1);
-       if (! uic->irqhost) {
-               of_node_put(node);
+       if (! uic->irqhost)
                return NULL; /* FIXME: panic? */
-       }
 
        uic->irqhost->host_data = uic;