From patchwork Mon Jan 4 06:57:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "james.chen" X-Patchwork-Id: 7946081 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F16F9F1C0 for ; Mon, 4 Jan 2016 07:09:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A422B20221 for ; Mon, 4 Jan 2016 07:09:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB19320218 for ; Mon, 4 Jan 2016 07:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbcADHIQ (ORCPT ); Mon, 4 Jan 2016 02:08:16 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:7564 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbcADHIQ (ORCPT ); Mon, 4 Jan 2016 02:08:16 -0500 Received: from unknown (HELO emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 04 Jan 2016 15:08:12 +0800 Received: from localhost.localdomain ([192.168.55.122]) by emc.com.tw (8.13.7+Sun/8.13.7) with ESMTP id u0477EPJ005180; Mon, 4 Jan 2016 15:07:15 +0800 (CST) From: "james.chen" To: Dmitry Torokhov , Herman Lin , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, charliemooney@chromium.org, Jennifer Tsai , Scott Liu Cc: "james.chen" Subject: [PATCH 2/2] Input: elants_i2c: fixed wake-on-touch issue Date: Mon, 4 Jan 2016 14:57:50 +0800 Message-Id: <1451890670-29705-1-git-send-email-james.chen@emc.com.tw> X-Mailer: git-send-email 1.8.3.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "james.chen" Fix function of wake-on-touch on suspend/resume. The function of device_may_wakeup will return true if the device supports wake-on-touch (for example, kitty and buddy). So, modify the code from "if (device_may_wakeup(dev))" to "if (!device_may_wakeup(dev))". And adjust the condition check of keep_power_in_suspend (designed for minnie). 2016.1.4: modify retry back to retry_cnt. Signed-off-by: james.chen --- drivers/input/touchscreen/elants_i2c.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 17cc20e..3739646 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -1316,24 +1316,25 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) disable_irq(client->irq); - if (device_may_wakeup(dev) || ts->keep_power_in_suspend) { + if (device_may_wakeup(dev)) { + /* + * The device will automatically enter idle mode + * that has reduced power consumption. + */ + ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); + } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { error = elants_i2c_send(client, set_sleep_cmd, - sizeof(set_sleep_cmd)); + sizeof(set_sleep_cmd)); if (!error) break; dev_err(&client->dev, "suspend command failed: %d\n", error); } - - if (device_may_wakeup(dev)) - ts->wake_irq_enabled = - (enable_irq_wake(client->irq) == 0); } else { - elants_i2c_power_off(ts); + elants_i2c_power_off(ts); } - return 0; } @@ -1345,13 +1346,14 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) int retry_cnt; int error; - if (device_may_wakeup(dev) && ts->wake_irq_enabled) - disable_irq_wake(client->irq); - - if (ts->keep_power_in_suspend) { + if (device_may_wakeup(dev)) { + if (ts->wake_irq_enabled) + disable_irq_wake(client->irq); + elants_i2c_sw_reset(client); + } else if (ts->keep_power_in_suspend) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { error = elants_i2c_send(client, set_active_cmd, - sizeof(set_active_cmd)); + sizeof(set_active_cmd)); if (!error) break; @@ -1362,7 +1364,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) elants_i2c_power_on(ts); elants_i2c_initialize(ts); } - ts->state = ELAN_STATE_NORMAL; enable_irq(client->irq);