If we press and release the power button before the press interrupt is handled - as can happen on resume - we lose the press event so the release event is ignored and we don't know what happened to cause the wakeup. So make sure that each interrupt handled does generate an event. Because twl4030 queues interrupt events we will see two interrupts for a press-release even if we handle the first one later. This means that such a sequence will be reported as two button presses. This is unfortunate but is better than no button presses. Possibly we could set the PENDDIS_MASK to disable queuing of interrupts, but that might adversely affect other interrupt sources. Signed-off-by: NeilBrown <neilb@xxxxxxx> diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c index 38e4b50..7ea0ea8 100644 --- a/drivers/input/misc/twl4030-pwrbutton.c +++ b/drivers/input/misc/twl4030-pwrbutton.c @@ -42,7 +42,19 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr) err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value, STS_HW_CONDITIONS); if (!err) { - input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ); + int val = !!(value & PWR_PWRON_IRQ); + + /* We got an interrupt, so we must see a change. + * Because the TWL4030 queues pending interrupts to a depth + * of 2, we end up seeing two key presses as there can + * be two interrupts processed while the key appears to + * be up. This could be fixed by setting PNEDDIS_MASK + * in PWR_SIH_CTRL in twl4030-irq.c. + */ + input_report_key(pwr, KEY_POWER, !val); + input_sync(pwr); + + input_report_key(pwr, KEY_POWER, val); input_sync(pwr); } else { dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"
Attachment:
signature.asc
Description: PGP signature