From patchwork Mon Jul 30 01:09:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 1253191 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 1EF82DF25A for ; Mon, 30 Jul 2012 01:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753902Ab2G3BJv (ORCPT ); Sun, 29 Jul 2012 21:09:51 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43016 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753747Ab2G3BJu (ORCPT ); Sun, 29 Jul 2012 21:09:50 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 7704398E46; Mon, 30 Jul 2012 03:09:49 +0200 (CEST) From: NeilBrown To: Dmitry Torokhov Date: Mon, 30 Jul 2012 11:09:02 +1000 Subject: [PATCH 1/2] Input: gpio_keys: report a wakeup_event for a button press on a wake_up button. Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, NeilBrown Message-ID: <20120730010901.22579.83689.stgit@notabene.brown> In-Reply-To: <20120730010746.22579.52841.stgit@notabene.brown> References: <20120730010746.22579.52841.stgit@notabene.brown> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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(). Signed-off-by: NeilBrown --- drivers/input/keyboard/gpio_keys.c | 7 +++++++ 1 file changed, 7 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 62bfce4..ee6e525 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -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);