From patchwork Wed Feb 26 15:28:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 25356 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C08A203C4 for ; Wed, 26 Feb 2014 15:28:52 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id hq11sf2458713vcb.0 for ; Wed, 26 Feb 2014 07:28:51 -0800 (PST) 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=vPppC0FVpIPU9nHijhRaTN1Q/1r0iw4Y8rlPLKb2qns=; b=ib5ch+k1rCGhchJWkuTHCnX8hWXF+iO7/Jxe+gipu23xIxv40QIPGgyhyPP5CXK51h jIGlv0FijoQsD0F7VCvvCsvoxYQ7b7+ir7mCej0WJ1AvFv7l0dPKIv/lYqPsMnkrRZNZ M/X8xMfSJVy3rc9L3uPsSjB4eU/VMgE817E2ern8F2Gilc/n+lFIiOWCk2Tgd+woE6fs eDIOim2ubbCWDf/3DxnhXkQdg3ut+PYFf/ByuUY1rQGUhm51SnoecmtK3EfRa0CrrO+B 04L9H5GnnOrHLkuURt1REdW7bbp9tRKhSsLUFbC2BRAmeen6ikeH4tqVblH3CfJkZgoY 2b5g== X-Gm-Message-State: ALoCoQlIq5rFpLM0zDj2PC9lU94jow4+pDNO2Utob9mkR9138o4202fjsS/s6ZAfo2sFX/1Wagwx X-Received: by 10.58.46.204 with SMTP id x12mr3636361vem.19.1393428531876; Wed, 26 Feb 2014 07:28:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls261797qgv.19.gmail; Wed, 26 Feb 2014 07:28:51 -0800 (PST) X-Received: by 10.52.186.230 with SMTP id fn6mr5534869vdc.14.1393428531755; Wed, 26 Feb 2014 07:28:51 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id xn5si300954vdc.3.2014.02.26.07.28.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 07:28:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id le5so1075919vcb.2 for ; Wed, 26 Feb 2014 07:28:51 -0800 (PST) X-Received: by 10.58.188.13 with SMTP id fw13mr44017vec.58.1393428531664; Wed, 26 Feb 2014 07:28:51 -0800 (PST) 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.174.196 with SMTP id u4csp34035vcz; Wed, 26 Feb 2014 07:28:51 -0800 (PST) X-Received: by 10.68.233.200 with SMTP id ty8mr7366092pbc.1.1393428530053; Wed, 26 Feb 2014 07:28:50 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si1415302pab.29.2014.02.26.07.28.48; Wed, 26 Feb 2014 07:28:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753363AbaBZP2i (ORCPT + 26 others); Wed, 26 Feb 2014 10:28:38 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:39875 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbaBZP2f (ORCPT ); Wed, 26 Feb 2014 10:28:35 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1QFSUhc014209; Wed, 26 Feb 2014 09:28:30 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1QFSUcv011435; Wed, 26 Feb 2014 09:28:30 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 26 Feb 2014 09:28:30 -0600 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 s1QFSAC8027272; Wed, 26 Feb 2014 09:28:28 -0600 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v2 6/8] Input: pixcir_i2c_ts: Implement wakeup from suspend Date: Wed, 26 Feb 2014 17:28:04 +0200 Message-ID: <1393428486-15001-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393428486-15001-1-git-send-email-rogerq@ti.com> References: <1393428486-15001-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: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 | 46 ++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index b1e92f6..8ca258b 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -345,21 +345,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)) { + /* need to start device if not open, to be wakeup source */ + if (!input->users) { + ret = pixcir_start(ts); + if (ret) + goto unlock; + } - if (device_may_wakeup(&client->dev)) enable_irq_wake(client->irq); - return 0; + } 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)) + if (device_may_wakeup(&client->dev)) { disable_irq_wake(client->irq); - return 0; + /* 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