Skip to contentSkip to conversation

Report wake_events for some button presses.

PATCH Applied NeilBrown 2 participants 4 messages Jul 30, 2012

Subsystems (2)
lore
Share & tools
lore
author
#1 lore raw

PATCH 1/2 Input: gpio_keys: report a wakeup_event for a button press on a wake_up button.

In reply to NeilBrown

In order to avoid races with suspend, a wakeup event must register as such by calling pm_wakeup_event() or pm_stay_awake(). This will ensure that the current suspend cycle aborts.

When the user-space visible event is created in the interrupt handler (gpio_keys_irq_isr), a simple pm_wakeup_event() with no delay is sufficient as suspend will synchronise with all interrupt delivery.

When the user-space visible event is created later (gpio_keys_gpio_isr), we need to bracket the event with pm_stay_awake() and pm_relax().

---

 drivers/input/keyboard/gpio_keys.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/keyboard/gpio_keys.c +7 -0
index 62bfce4..ee6e525 100644
@@ -346,6 +346,8 @@ static void gpio_keys_gpio_work_func(struct work_struct *work)
 		container_of(work, struct gpio_button_data, work);
 
 	gpio_keys_gpio_report_event(bdata);
+	if (bdata->button->wakeup)
+		pm_relax(bdata->input->dev.parent);
 }
 
 static void gpio_keys_gpio_timer(unsigned long _data)
@@ -361,6 +363,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 
 	BUG_ON(irq != bdata->irq);
 
+	if (bdata->button->wakeup)
+		pm_stay_awake(bdata->input->dev.parent);
 	if (bdata->timer_debounce)
 		mod_timer(&bdata->timer,
 			jiffies + msecs_to_jiffies(bdata->timer_debounce));
@@ -397,6 +401,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
 	spin_lock_irqsave(&bdata->lock, flags);
 
 	if (!bdata->key_pressed) {
+		if (bdata->button->wakeup)
+			pm_wakeup_event(bdata->input->dev.parent, 0);
+
 		input_event(input, EV_KEY, button->code, 1);
 		input_sync(input);
 
author
#2 lore raw

PATCH 2/2 Input: twl4030-pwrbutton: report a wakeup_event on button press.

In reply to NeilBrown

As the power button causes a wake from suspend, we need to register the event with the pm sustem to avoid racing with suspend.

As the input event is reported in the interrupt handler, as simple pm_wakeup_event() is sufficient.

---

 drivers/input/misc/twl4030-pwrbutton.c |    1 +
 1 file changed, 1 insertion(+)
drivers/input/misc/twl4030-pwrbutton.c +1 -0
index 38e4b50..b3dd96d 100644
@@ -42,6 +42,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
 	err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
 				STS_HW_CONDITIONS);
 	if (!err)  {
+		pm_wakeup_event(pwr->dev.parent, 0);
 		input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
 		input_sync(pwr);
 	} else {

NeilBrown

author
#0 lore raw

cover Report wake_events for some button presses.

To avoid racing with suspend, we need to report wakeup events to the pm subsystem when they happen.
These two patches do this for gpio_keys and twl4030-pwrbutton.

---

NeilBrown (2):
Input: twl4030-pwrbutton: report a wakeup_event on button press.
Input: gpio_keys: report a wakeup_event for a button press on a wake_up button.

 drivers/input/keyboard/gpio_keys.c     |    7 +++++++
 drivers/input/misc/twl4030-pwrbutton.c |    1 +
 2 files changed, 8 insertions(+)
Signature · 1 line
Signature
maintainer Applied
#3 lore raw
Quoted 10 lines · NeilBrown

To avoid racing with suspend, we need to report wakeup events to the pm subsystem when they happen.
These two patches do this for gpio_keys and twl4030-pwrbutton.

---

NeilBrown (2):
Input: twl4030-pwrbutton: report a wakeup_event on button press.
Input: gpio_keys: report a wakeup_event for a button press on a wake_up button.

Applied both, thanks Neil.

Signature · 1 line
Dmitry