Skip to contentSkip to conversation

at91: fix enable/disable_irq_wake symmetry in pcmcia driver

PATCH In review Marc Pignat 3 participants 3 messages May 10, 2007 – May 11, 2007

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

PATCH v2 1/1 at91: fix enable/disable_irq_wake symmetry in pcmcia driver

from Marc Pignat <[email protected]>

fix enable_irq_wake and disable_irq_wake symmetry in at91 pcmcia driver

---
Please forget the [PATCH] at91: fix enable/disable_irq_wake symmetry in pcmcia driver, it doesn't compile... Here is the good patch!

This patch applies to the 2.6.21.1 kernel.

disable_irq_wake call must be symmetric with enable_irq_wake. This patch fix that problem for the at91_pcmia driver.
It seems that this patch was forgotten when we've fixed irq_wake symmetry in all at91 related drivers.
It was discussed in the "at91 drivers and [enable/disable]_irq_wake (wrong?) usage" thread on the linux-arm-kernel mailing list.

Regards

Marc

drivers/pcmcia/at91_cf.c renamed from drivers/pcmcia/at91_cf.c.orig +9 -4
@@ -336,16 +336,21 @@ static int at91_cf_suspend(struct platfo
 		enable_irq_wake(board->det_pin);
 		if (board->irq_pin)
 			enable_irq_wake(board->irq_pin);
-	} else {
-		disable_irq_wake(board->det_pin);
-		if (board->irq_pin)
-			disable_irq_wake(board->irq_pin);
 	}
 	return 0;
 }
 
 static int at91_cf_resume(struct platform_device *pdev)
 {
+	struct at91_cf_socket	*cf = platform_get_drvdata(pdev);
+	struct at91_cf_data	*board = cf->board;
+
+	if (device_may_wakeup(&pdev->dev)) {
+		disable_irq_wake(board->det_pin);
+		if (board->irq_pin)
+			disable_irq_wake(board->irq_pin);
+	}
+
 	pcmcia_socket_dev_resume(&pdev->dev);
 	return 0;
 }
#1 lore raw
Quoted 9 lines · On Thu, 10 May 2007 10:09:35 +0200 Marc Pignat <[email protected]> wrote:

from Marc Pignat <[email protected]>

fix enable_irq_wake and disable_irq_wake symmetry in at91 pcmcia driver

---
Please forget the [PATCH] at91: fix enable/disable_irq_wake symmetry in pcmcia driver, it doesn't compile... Here is the good patch!

Quoted 8 lines

This patch applies to the 2.6.21.1 kernel.

disable_irq_wake call must be symmetric with enable_irq_wake. This patch fix that problem for the at91_pcmia driver.
It seems that this patch was forgotten when we've fixed irq_wake symmetry in all at91 related drivers.
It was discussed in the "at91 drivers and [enable/disable]_irq_wake (wrong?) usage" thread on the linux-arm-kernel mailing list.

That's not a terribly useful changelog, sorry. I look at the patch and I don't know what was wrong with the old code, nor how this new code improves things.

"disable_irq_wake call must be symmetric with enable_irq_wake". hmm, OK, I'll take your word for it.

Does the present code actually fail in some manner, or what?

#2 lore raw
Quoted 2 lines · Andrew Morton

"disable_irq_wake call must be symmetric with enable_irq_wake". hmm, OK, I'll take your word for it.

In the same way that enable_irq() and disable_irq() must be matched, and for the same reasons: when the IRQ is shared between drivers, they can't all treat enable/disable status as boolean. Those calls mask refcountig.

Quoted 1 line

Does the present code actually fail in some manner, or what?

Yes ... runtime warnings flagging various misbehaviors associated with refcount mismatches.

- Dave