From patchwork Thu Nov 22 13:23:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13072 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 E7CF123FC6 for ; Thu, 22 Nov 2012 13:23:45 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 92209A18B24 for ; Thu, 22 Nov 2012 13:23:45 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so554892ieb.11 for ; Thu, 22 Nov 2012 05:23:44 -0800 (PST) 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=P9KTyS7DG5OaeE5+tn/skbqoXb5PQK51k+eqM3GZWWQ=; b=F8YmMIjyLRThQBPfF/qlaW80599dEQuf2FGqJ29hc3SsBNVKunPHAuOVp1vY30snNX uj9KWG2NIKSKRkqPq/StTlUAJaIywcZiMEE1sPVyEeGNXxuDiq7mjPzJnNeqDGqv1mvL QenkQlZB1qaLgEHAE2Ek5Gu/8MoS1TAXoWEmTUPW+/0hHhoLQkRWMo60yhc9EwvzzabL xYvF2WaYXlhf9gi1GfFWj39kh+WiFMUj0pnmM1inNIqLh5Wqg2KuwZLrKepuIfDL0tW/ /vV2cEgY8TIL3Xz4RNWxW4NrGtkkYyWI8QI2VV2mPa8lLRbcNAqh84bjXgUCgd6nA9n8 JsPg== Received: by 10.43.125.133 with SMTP id gs5mr416888icc.54.1353590624776; Thu, 22 Nov 2012 05:23:44 -0800 (PST) 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 n20csp208405igt; Thu, 22 Nov 2012 05:23:43 -0800 (PST) Received: by 10.216.205.133 with SMTP id j5mr261795weo.135.1353590622908; Thu, 22 Nov 2012 05:23:42 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id y84si1818171wep.54.2012.11.22.05.23.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 05:23:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.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-wi0-f178.google.com with SMTP id hm6so626884wib.13 for ; Thu, 22 Nov 2012 05:23:42 -0800 (PST) Received: by 10.180.72.232 with SMTP id g8mr4656510wiv.0.1353590622200; Thu, 22 Nov 2012 05:23:42 -0800 (PST) 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 bz12sm4507489wib.5.2012.11.22.05.23.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 05:23:40 -0800 (PST) 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, Lee Jones , Philippe Langlais Subject: [PATCH 1/2] input: gpio-keys: Disable hardware on suspend Date: Thu, 22 Nov 2012 13:23:36 +0000 Message-Id: <1353590617-11466-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmqdVwAThZQ+L5+afyHlnUYK6M3JnIHK2UnQUwLIjWbcKwhO0ZAybnKKAb+bw4kfSAcuK4c 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 Signed-off-by: Lee Jones Signed-off-by: Jonas Aaberg Signed-off-by: Philippe Langlais Reviewed-by: Bengt Jonsson --- drivers/input/keyboard/gpio_keys.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 6a68041..2cf6757 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -46,6 +46,8 @@ struct gpio_keys_drvdata { const struct gpio_keys_platform_data *pdata; struct input_dev *input; struct mutex disable_lock; + bool enabled; + bool enable_after_suspend; struct gpio_button_data data[0]; }; @@ -531,6 +533,8 @@ static int gpio_keys_open(struct input_dev *input) struct gpio_keys_drvdata *ddata = input_get_drvdata(input); const struct gpio_keys_platform_data *pdata = ddata->pdata; + ddata->enabled = true; + return pdata->enable ? pdata->enable(input->dev.parent) : 0; } @@ -539,6 +543,8 @@ static void gpio_keys_close(struct input_dev *input) struct gpio_keys_drvdata *ddata = input_get_drvdata(input); const struct gpio_keys_platform_data *pdata = ddata->pdata; + ddata->enabled = false; + if (pdata->disable) pdata->disable(input->dev.parent); } @@ -685,6 +691,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->pdata = pdata; ddata->input = input; + ddata->enabled = false; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); @@ -796,6 +803,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; @@ -814,6 +825,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;