Skip to contentSkip to conversation

arch/powerpc/platforms/powermac/pic.c: move of_node_put

PATCH In review Julia Lawall 2 participants 2 messages Sep 21, 2008 – Sep 22, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch/powerpc/platforms/powermac/pic.c: move of_node_put

From: Julia Lawall <[email protected]>

It seems better to dereference master before decrementing the reference count rather than afterwards.

The problem was found using the following semantic match:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
expression n,E;
identifier fld;
iterator I;
statement S;
@@

* of_node_put(n)
... when != n = E

    when != I(n,...) S

* n->fld
// </smpl>

---

 arch/powerpc/platforms/powermac/pic.c          |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/platforms/powermac/pic.c +1 -1
index 6d149ae..d17aa2b 100644
@@ -395,10 +395,10 @@ static void __init pmac_pic_probe_oldstyle(void)
 	if (max_real_irqs > 32)
 		pmac_irq_hw[i++] = (volatile struct pmac_irq_hw __iomem *)
 			(addr + 0x10);
-	of_node_put(master);
 
 	printk(KERN_INFO "irq: Found primary Apple PIC %s for %d irqs\n",
 	       master->full_name, max_real_irqs);
+	of_node_put(master);
 
 	/* Map interrupts of cascaded controller */
 	if (slave && !of_address_to_resource(slave, 0, &r)) {
#1 lore raw
Quoted 16 lines · Julia Lawall

From: Julia Lawall <[email protected]>

It seems better to dereference master before decrementing the reference count rather than afterwards.

The problem was found using the following semantic match:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
expression n,E;
identifier fld;
iterator I;
statement S;
@@

Quoted 7 lines

* of_node_put(n)
... when != n = E

    when != I(n,...) S

* n->fld
// </smpl>

Ack.

No big deal, tho, those nodes are never going to go away :-)

Cheers,
Ben.

Quoted 21 lines

---

 arch/powerpc/platforms/powermac/pic.c          |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/platforms/powermac/pic.c +1 -1
index 6d149ae..d17aa2b 100644
@@ -395,10 +395,10 @@ static void __init pmac_pic_probe_oldstyle(void)
 	if (max_real_irqs > 32)
 		pmac_irq_hw[i++] = (volatile struct pmac_irq_hw __iomem *)
 			(addr + 0x10);
-	of_node_put(master);
 
 	printk(KERN_INFO "irq: Found primary Apple PIC %s for %d irqs\n",
 	       master->full_name, max_real_irqs);
+	of_node_put(master);
 
 	/* Map interrupts of cascaded controller */
 	if (slave && !of_address_to_resource(slave, 0, &r)) {