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: 12165 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 015491A55A1 for ; Thu, 11 Oct 2012 14:15:48 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9F414A18098 for ; Thu, 11 Oct 2012 14:15:47 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so1252926iag.11 for ; Thu, 11 Oct 2012 07:15:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=t95rL2JVJFniN93ZVzM/jrqz8VPppCQPVFqKX/a9S68=; b=YOipAUo8L7Yz1LUxB7ooJk6dY8CcvvO1ppktl8m/LgOGHmjX5oNSfHV2XqNcBxwFOP FpRYjUzduIeLzbrpsoyD9/UtfhT2RC6LbCVGVSIj0bQhdl2XtHabUgyLZtSC/I7BSXVS ShPMQQbFIUUAtrZ5UbvliHHr0qj1cYcsRUU3Ed6b+hLgELiOIr74w8oMsK+PsN3P0gaA se/wU50fmh/rAeIdPTuzlvvrjuX2dCj4N1RrddaD595rGXg1VpoEbSMQtr257celRCWO OOecOta8jAHoUiFN7kqmdGcgTGcciw0Fa0YjECmb0u5Nb7WMOdIv0B8oEUWQHyA7HOws LMJw== Received: by 10.50.46.226 with SMTP id y2mr893708igm.62.1349964946903; Thu, 11 Oct 2012 07:15:46 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp41458igt; Thu, 11 Oct 2012 07:15:45 -0700 (PDT) Received: by 10.180.90.201 with SMTP id by9mr21152746wib.5.1349964944912; Thu, 11 Oct 2012 07:15:44 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id o8si5254256wea.75.2012.10.11.07.15.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 07:15:44 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f178.google.com with SMTP id r6so1263443wey.37 for ; Thu, 11 Oct 2012 07:15:44 -0700 (PDT) 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 Cc: arnd@arndb.de, linus.walleij@stericsson.com, Jonas Aaberg , Dmitry Torokhov , linux-input@vger.kernel.org, Philippe Langlais 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: ALoCoQnFyeUbco1FMR1DswX0hbJyBIvZYFfCHoa5of0GeRFFKjinKBPcq+rgIKT1PFKsQap9msMZ 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;