From patchwork Tue May 6 11:06:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 29692 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1CE7B20534 for ; Tue, 6 May 2014 11:07:05 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf17915941igq.10 for ; Tue, 06 May 2014 04:07:05 -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=vagU4U1YY6nszSnmZ3e1TVLfrVYzyaeP2+WbN5X1yRs=; b=dWLZe4hIBpy0WohmjvM0nwkBTtGb3p5XtjqjLIGdzVn8Z0d4sEFw+hzByQWybz62Gj J0JW9Kalb03uLPicaMtYzPYXgYchoGJ2r55ndS+kb700MQi66nViNSB9N5TtxCapCzMm VGrd31PFhNM+JYykmmSuS/zWX/GJcltL3Iz77hTV3h7Ta1/jwyOpBspSG01Rseg2gYWV 0NfRLbULUq5VgGp1oAnqTIuzpCjz3YSyE+c5OvxOAKqK84QuETh0psbtcxRfpGpTZGaj gH0OEitBYz7Y3fjMmQKVEGT0WCv/rS/auuSsm8nNyehytd1DUO0X+nmRmvzbc0+oTV0K JzlQ== X-Gm-Message-State: ALoCoQkfhMCC0E9MzKrrpaEqXipdux5w9Fc8NpEeJM0U7D834wCKKIMlIp8lKwYm9rGbQj601Y1h X-Received: by 10.182.78.97 with SMTP id a1mr790002obx.33.1399374425267; Tue, 06 May 2014 04:07:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.107 with SMTP id b98ls2851362qgd.64.gmail; Tue, 06 May 2014 04:07:05 -0700 (PDT) X-Received: by 10.58.202.133 with SMTP id ki5mr32021111vec.19.1399374425148; Tue, 06 May 2014 04:07:05 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id gq7si1097345vdc.122.2014.05.06.04.07.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 May 2014 04:07:05 -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.220.176; Received: by mail-vc0-f176.google.com with SMTP id lg15so703772vcb.35 for ; Tue, 06 May 2014 04:07:05 -0700 (PDT) X-Received: by 10.221.67.67 with SMTP id xt3mr434217vcb.41.1399374425052; Tue, 06 May 2014 04:07:05 -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 ib8csp213672vcb; Tue, 6 May 2014 04:07:04 -0700 (PDT) X-Received: by 10.66.148.134 with SMTP id ts6mr5142609pab.113.1399374424070; Tue, 06 May 2014 04:07:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci3si11765618pad.4.2014.05.06.04.07.03; Tue, 06 May 2014 04:07:03 -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 S934938AbaEFLGr (ORCPT + 27 others); Tue, 6 May 2014 07:06:47 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:36978 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934895AbaEFLGn (ORCPT ); Tue, 6 May 2014 07:06:43 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s46B6ftP015549; Tue, 6 May 2014 06:06:41 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s46B6fEZ026140; Tue, 6 May 2014 06:06:41 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 6 May 2014 06:06:40 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s46B6KfB021055; Tue, 6 May 2014 06:06:38 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v5 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend Date: Tue, 6 May 2014 14:06:11 +0300 Message-ID: <1399374372-29123-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399374372-29123-1-git-send-email-rogerq@ti.com> References: <1399374372-29123-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 | 47 ++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 0728c04..b0f7680 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -348,21 +348,59 @@ 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 (device_may_wakeup(&client->dev)) { + if (!input->users) { + ret = pixcir_start(ts); + if (ret) { + dev_err(dev, "Failed to start\n"); + goto unlock; + } + } - if (device_may_wakeup(&client->dev)) enable_irq_wake(client->irq); + } else if (input->users) { + ret = pixcir_stop(ts); + } - 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; + + mutex_lock(&input->mutex); - if (device_may_wakeup(&client->dev)) + if (device_may_wakeup(&client->dev)) { disable_irq_wake(client->irq); - return 0; + if (!input->users) { + ret = pixcir_stop(ts); + if (ret) { + dev_err(dev, "Failed to stop\n"); + goto unlock; + } + } + } else if (input->users) { + ret = pixcir_start(ts); + } + +unlock: + mutex_unlock(&input->mutex); + + return ret; } #endif @@ -469,6 +507,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, if (error) return error; + i2c_set_clientdata(client, tsdata); device_init_wakeup(&client->dev, 1); return 0;