Dne St 22. července 2009 00:39:00 Marek Vasut napsal(a):
Dne St 22. července 2009 00:33:34 Russell King - ARM Linux napsal(a):
On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
IRQ_TYPE_EDGE_BOTH);
if (ret)
goto err2;
ret = request_irq(gpio_to_irq(pdata->charge_gpio),
wm97xx_chrg_irq, IRQF_DISABLED,
"AC Detect", 0);
This should be done as one call to request_irq().
Why?
If the IRQ is already in use by something else, calling set_irq_type() will stamp on that other user, enforcing the change of configuration. request_irq() will then fail, leaving the IRQ configuration buggered.
Combining the two allows request_irq() to fail if the IRQ line is busy. If it isn't busy, it will configure the IRQ line prior to enabling the IRQ. If the IRQ is shared and sharing is permitted, it will fail if the configuration is not compatible with the existing IRQ configuration.
set_irq_type() should only be used very sparingly and when there's no other option.
Sorry, I removed that, this patch should be OK.
Argh, I forget to fix the goto label.