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: 29624 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 42A402055D for ; Mon, 5 May 2014 09:05:35 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id z6sf1484519yhz.4 for ; Mon, 05 May 2014 02:05:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=lr1QlRShvBw2KSbmcq9z8JdQebaAqQyoRtE1r2flUYk=; b=TakfkBcDNm+5GYjL6IkEj6BWOwtJZzZ8vhtYrTTa2leufyMyyADjJbPDBYTTIrxqok 2dqeQ+vu83YVhTlzYIla+6uNuDkUm8v6dhTErJtglxcf6xpVacYFLhCdBk5PZbVgqC5s F1DJDVB3W41dVwF0FsgR81WHP4IzZmRxwbPc242pZuuAZTiTTgW7BFtoi+1UQkBWZeKN VzRKh8Ci6iunZQl/o865SF4FevaVwG7dUNWVxBqtAG0lT+1amCyVZQ0ysEbkY5kBi54o Pd4gJ6p5FmTKt9SFdoKLjBrNgq98SiV/A248KkHIeVHSZ0lu/SXbNJREwLHz8MnfczAN ckSQ== X-Gm-Message-State: ALoCoQnAE3MUwat//ejcknkh/tDrLd3NpwQ4q4L83LRQr+o8U5WUrji06wdmHNYG70PKFHWE8/z9 X-Received: by 10.58.196.209 with SMTP id io17mr16986610vec.7.1399280734956; Mon, 05 May 2014 02:05:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.201 with SMTP id f67ls2336736qgd.91.gmail; Mon, 05 May 2014 02:05:34 -0700 (PDT) X-Received: by 10.58.126.4 with SMTP id mu4mr27889434veb.0.1399280734848; Mon, 05 May 2014 02:05:34 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id sw4si1416085vdc.84.2014.05.05.02.05.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 02:05:34 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id sa20so2014051veb.23 for ; Mon, 05 May 2014 02:05:34 -0700 (PDT) X-Received: by 10.52.113.1 with SMTP id iu1mr613471vdb.35.1399280734743; Mon, 05 May 2014 02:05:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp124334vcb; Mon, 5 May 2014 02:05:34 -0700 (PDT) X-Received: by 10.43.106.137 with SMTP id du9mr286972icc.93.1399280733892; Mon, 05 May 2014 02:05:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qd9si7798655pac.269.2014.05.05.02.05.33; Mon, 05 May 2014 02:05:33 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932080AbaEEJFH (ORCPT + 27 others); Mon, 5 May 2014 05:05:07 -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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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