From patchwork Mon May 5 09:04:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 4112731 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 8CA59BFF02 for ; Mon, 5 May 2014 09:06:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B87D820254 for ; Mon, 5 May 2014 09:06:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4F2B2021A for ; Mon, 5 May 2014 09:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755651AbaEEJFF (ORCPT ); Mon, 5 May 2014 05:05:05 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:48038 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755602AbaEEJFD (ORCPT ); Mon, 5 May 2014 05:05:03 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s45951eX012298; Mon, 5 May 2014 04:05:01 -0500 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 s45951TO012824; Mon, 5 May 2014 04:05:01 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Mon, 5 May 2014 04:05:01 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4594ep5022901; Mon, 5 May 2014 04:04:58 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v4 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend Date: Mon, 5 May 2014 12:04:37 +0300 Message-ID: <1399280678-23925-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399280678-23925-1-git-send-email-rogerq@ti.com> References: <1399280678-23925-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.5 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 | 53 ++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 927aed1..5f6a27e 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -348,21 +348,66 @@ static void pixcir_input_close(struct input_dev *dev) 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 (input->users) { + ret = pixcir_stop(ts); + if (ret) + goto unlock; + } + + /* + * If wakeup is enabled we need to enable interrupt generation + * but don't need to process any reports i.e. ts->exiting must be true. + */ + if (device_may_wakeup(&client->dev)) { + /* enable wakeup interrupt generation */ + ret = pixcir_int_enable(ts, 1); + if (ret) { + dev_err(dev, "Failed to enable interrupt generation\n"); + goto unlock; + } - if (device_may_wakeup(&client->dev)) enable_irq_wake(client->irq); + } - return 0; +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; - if (device_may_wakeup(&client->dev)) + mutex_lock(&input->mutex); + + if (device_may_wakeup(&client->dev)) { disable_irq_wake(client->irq); - return 0; + /* disable wakeup interrupt generation */ + ret = pixcir_int_enable(ts, 0); + if (ret) { + dev_err(dev, "Failed to disable interrupt generation\n"); + goto unlock; + } + } + + if (input->users) + ret = pixcir_start(ts); + +unlock: + mutex_unlock(&input->mutex); + + return ret; } #endif