From patchwork Wed Dec 18 09:21:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 3368951 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C076C0D4A for ; Wed, 18 Dec 2013 09:24:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FA8F2044C for ; Wed, 18 Dec 2013 09:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86A6220453 for ; Wed, 18 Dec 2013 09:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753819Ab3LRJX0 (ORCPT ); Wed, 18 Dec 2013 04:23:26 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:40344 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753382Ab3LRJXJ (ORCPT ); Wed, 18 Dec 2013 04:23:09 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBI9N3ES027233; Wed, 18 Dec 2013 03:23:03 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBI9N3RI014069; Wed, 18 Dec 2013 03:23:03 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Wed, 18 Dec 2013 03:23:03 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBI9LjU1008288; Wed, 18 Dec 2013 03:22:59 -0600 From: Roger Quadros To: CC: , , , , , Roger Quadros Subject: [PATCH 9/9] Input: pixcir_i2c_ts: Implement wakeup from suspend Date: Wed, 18 Dec 2013 14:51:20 +0530 Message-ID: <1387358480-8313-10-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1387358480-8313-1-git-send-email-rogerq@ti.com> References: <1387358480-8313-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Improve the suspend and resume handlers to allow the device to wakeup the system from suspend. Signed-off-by: Roger Quadros Acked-by: Mugunthan V N --- drivers/input/touchscreen/pixcir_i2c_ts.c | 89 ++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 26 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 3575eab..a7725b9 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -347,32 +347,6 @@ static void pixcir_input_close(struct input_dev *dev) return; } - -#ifdef CONFIG_PM_SLEEP -static int pixcir_i2c_ts_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - if (device_may_wakeup(&client->dev)) - enable_irq_wake(client->irq); - - return 0; -} - -static int pixcir_i2c_ts_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - - if (device_may_wakeup(&client->dev)) - disable_irq_wake(client->irq); - - return 0; -} -#endif - -static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops, - pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume); - #if defined(CONFIG_OF) static const struct of_device_id pixcir_of_match[]; @@ -547,6 +521,69 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM_SLEEP +static int pixcir_i2c_ts_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client); + struct input_dev *input = ts->input; + int ret = 0; + + mutex_lock(&input->mutex); + + if (device_may_wakeup(&client->dev)) { + /* need to start device if not open, to be wakeup source */ + if (!input->users) { + ret = pixcir_start(ts); + if (ret) + goto unlock; + } + + enable_irq_wake(client->irq); + + } else if (input->users) { + ret = pixcir_stop(ts); + } + +unlock: + mutex_unlock(&input->mutex); + + return ret; +} + +static int pixcir_i2c_ts_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client); + struct input_dev *input = ts->input; + int ret = 0; + + mutex_lock(&input->mutex); + + if (device_may_wakeup(&client->dev)) { + disable_irq_wake(client->irq); + + /* need to stop device if it was not open on suspend */ + if (!input->users) { + ret = pixcir_stop(ts); + if (ret) + goto unlock; + } + + } else if (input->users) { + ret = pixcir_start(ts); + } + +unlock: + mutex_unlock(&input->mutex); + + return ret; +} +#endif + +static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops, + pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume); + static const struct i2c_device_id pixcir_i2c_ts_id[] = { { "pixcir_ts", 0 }, { "pixcir_tangoc", 0},