From patchwork Wed Apr 30 12:36:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 29418 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 61E4F203F3 for ; Wed, 30 Apr 2014 12:37:30 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id l6sf5290820qcy.7 for ; Wed, 30 Apr 2014 05:37:30 -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=dgC7fagbvRNV9fCWzXtH4lMws/A5EU+sADgCKCakpLQ=; b=hvKhZc+krWANuIjMnUVITWiYPvYwhoIGsZflbllztgwaJhkBvo2mS/jeXtWrryfPPg cCDeHWKYNtqPaRKXFVA5umunuCuHMFF8/Kq8aJ90vfuKBa+prblHNOxdY0HBGmFmO01j UWTXS0zRazhf132+/TCnZmjVBRmb17oadpJ0oNbQ9pAzCdOA/hcksnRpEPkaQiAszSQl dD6ssuaw7T8uhU1oxEOZ2UIAPlTg48XZs7tut7+ODY13iXSl6/7gijzWTf265MKpMQyo bt3nbWSxTYlKVDjM5R+PjTLys95kokfgFUe5WOUTwscTqFZXENfSHlBnEH4VerYB1+CE 9L9w== X-Gm-Message-State: ALoCoQnDdb6wFDFYnndjJpuDzLXOUzqsGo7HgH5NY6K+PyNsiW2weFIakvUa2VKiNlRpC8OqL0Iy X-Received: by 10.52.143.35 with SMTP id sb3mr1917541vdb.7.1398861450182; Wed, 30 Apr 2014 05:37:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.231 with SMTP id q94ls581834qga.28.gmail; Wed, 30 Apr 2014 05:37:30 -0700 (PDT) X-Received: by 10.58.150.68 with SMTP id ug4mr103438veb.50.1398861450032; Wed, 30 Apr 2014 05:37:30 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id ui2si5273788vdc.10.2014.04.30.05.37.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Apr 2014 05:37:30 -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.179; Received: by mail-ve0-f179.google.com with SMTP id db12so2085957veb.10 for ; Wed, 30 Apr 2014 05:37:30 -0700 (PDT) X-Received: by 10.58.98.232 with SMTP id el8mr106342veb.42.1398861449948; Wed, 30 Apr 2014 05:37:29 -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 ib8csp275397vcb; Wed, 30 Apr 2014 05:37:29 -0700 (PDT) X-Received: by 10.66.254.234 with SMTP id al10mr8006713pad.137.1398861449190; Wed, 30 Apr 2014 05:37:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pb4si16843651pac.318.2014.04.30.05.37.28 for ; Wed, 30 Apr 2014 05:37:28 -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 S1422671AbaD3MhE (ORCPT + 28 others); Wed, 30 Apr 2014 08:37:04 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:54802 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933624AbaD3Mg7 (ORCPT ); Wed, 30 Apr 2014 08:36:59 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3UCauVV009033; Wed, 30 Apr 2014 07:36:56 -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 s3UCau6w006183; Wed, 30 Apr 2014 07:36:56 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 30 Apr 2014 07:36:56 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3UCaZTG018190; Wed, 30 Apr 2014 07:36:53 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v3 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend Date: Wed, 30 Apr 2014 15:36:31 +0300 Message-ID: <1398861392-8959-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398861392-8959-1-git-send-email-rogerq@ti.com> References: <1398861392-8959-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 b3ff62c..ea31e20 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -352,21 +352,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