From patchwork Thu Oct 11 14:15:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1582191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 3F0033FD9C for ; Thu, 11 Oct 2012 14:17:48 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TMJYC-0001a3-IV; Thu, 11 Oct 2012 14:15:48 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TMJY9-0001ZW-Vh for linux-arm-kernel@lists.infradead.org; Thu, 11 Oct 2012 14:15:46 +0000 Received: by mail-we0-f177.google.com with SMTP id u50so1082070wey.36 for ; Thu, 11 Oct 2012 07:15:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=t95rL2JVJFniN93ZVzM/jrqz8VPppCQPVFqKX/a9S68=; b=ej/pzdyfx2uRteKpQkbAW/63nmxQdjStQ62SRiz4ZEAiwN6kj+JokkqDJTrGcEckLV uYOMz1dCUDYcY7KxnxbbEobWfvLpBOIzPelCLFnWMTA9F7M27K0zc/VH21V/ez6AGU+x G0JqL0AMGBddrx08Qq13r9jsbLy6tw9VmJkAkm976M5dvwvLTgXoVB23WeOL+3O8BYSk dxMPdUd8JZRxQK9LFDGWHiG0Zs+pECY6hfVFuTBdNjGx3PWCpkqX3Eb4M40zggg0F7up Vq8TkY4WohDM/KuJyg8bSR8aayYkCNkhVpowAf8ThIBpnRyrOiy8O/GGjaoKYGBrbBEG hZZQ== Received: by 10.216.217.38 with SMTP id h38mr584419wep.82.1349964944012; Thu, 11 Oct 2012 07:15:44 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id j8sm35579480wiy.9.2012.10.11.07.15.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 07:15:43 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] input: gpio-keys: Disable hardware on suspend Date: Thu, 11 Oct 2012 15:15:26 +0100 Message-Id: <1349964927-18619-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQl+TLm98dKikKRoNM6NoLTdrhaN4iHza/8JYMiHzorCPo034WR4+cwYxsdUOSwvg5Wwq7HL X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linus.walleij@stericsson.com, Jonas Aaberg , Philippe Langlais , Dmitry Torokhov , arnd@arndb.de, linux-input@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jonas Aaberg Disable hardware if active when suspending if the hw can not wake the system from suspend. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Acked-by: Lee Jones Signed-off-by: Jonas Aaberg Signed-off-by: Philippe Langlais Reviewed-by: Bengt Jonsson --- drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index cbb1add..7947315 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -46,6 +46,8 @@ struct gpio_keys_drvdata { struct input_dev *input; struct mutex disable_lock; unsigned int n_buttons; + bool enabled; + bool enable_after_suspend; int (*enable)(struct device *dev); void (*disable)(struct device *dev); struct gpio_button_data data[0]; @@ -524,6 +526,7 @@ static int gpio_keys_open(struct input_dev *input) { struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + ddata->enabled = true; return ddata->enable ? ddata->enable(input->dev.parent) : 0; } @@ -533,6 +536,7 @@ static void gpio_keys_close(struct input_dev *input) if (ddata->disable) ddata->disable(input->dev.parent); + ddata->enabled = false; } /* @@ -674,6 +678,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; + ddata->enabled = false; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); @@ -789,6 +794,10 @@ static int gpio_keys_suspend(struct device *dev) if (bdata->button->wakeup) enable_irq_wake(bdata->irq); } + } else { + ddata->enable_after_suspend = ddata->enabled; + if (ddata->enabled) + gpio_keys_close(ddata->input); } return 0; @@ -807,6 +816,10 @@ static int gpio_keys_resume(struct device *dev) if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } + + if (!device_may_wakeup(dev) && ddata->enable_after_suspend) + gpio_keys_open(ddata->input); + input_sync(ddata->input); return 0;