From patchwork Sun Nov 9 11:56:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 5260331 Return-Path: X-Original-To: patchwork-linux-arm@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 78CC5C11AC for ; Sun, 9 Nov 2014 12:00:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F2532015D for ; Sun, 9 Nov 2014 12:00:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B887020158 for ; Sun, 9 Nov 2014 12:00:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XnR7D-00010C-8V; Sun, 09 Nov 2014 11:57:07 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XnR78-0000xo-IW for linux-arm-kernel@lists.infradead.org; Sun, 09 Nov 2014 11:57:04 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 8853381D8E; Sun, 9 Nov 2014 12:56:37 +0100 (CET) Date: Sun, 9 Nov 2014 12:56:37 +0100 From: Pavel Machek To: pali.rohar@gmail.com, sre@debian.org, sre@ring0.de, kernel list , linux-arm-kernel , linux-omap@vger.kernel.org, tony@atomide.com, khilman@kernel.org, aaro.koskinen@iki.fi, freemangordon@abv.bg, B38611@freescale.com, jg1.han@samsung.com, linux-input@vger.kernel.org Subject: tsc2005 touchscreen: implement disable attribute Message-ID: <20141109115636.GA3106@amd> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141109_035702_897258_63C9B400 X-CRM114-Status: GOOD ( 19.03 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_RHS_DOB 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 Implement disable attribute for tsc2005 touchscreen. It is useful to avoid wakeups when phone is in the pocket. Signed-off-by: Pavel Machek --- [This is from Pali's n900 tree that is GPL, so that is okay, but maybe I should get his sign-off here?] diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c index 52380b6..ec1c276 100644 --- a/drivers/input/touchscreen/tsc2005.c +++ b/drivers/input/touchscreen/tsc2005.c @@ -147,6 +147,7 @@ struct tsc2005 { unsigned int x_plate_ohm; + bool disabled; bool opened; bool suspended; @@ -384,6 +385,48 @@ static void __tsc2005_enable(struct tsc2005 *ts) } +static ssize_t tsc2005_disable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct spi_device *spi = to_spi_device(dev); + struct tsc2005 *ts = spi_get_drvdata(spi); + + return sprintf(buf, "%u\n", ts->disabled); +} + +static ssize_t tsc2005_disable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct spi_device *spi = to_spi_device(dev); + struct tsc2005 *ts = spi_get_drvdata(spi); + unsigned long val; + int error; + + error = kstrtoul(buf, 10, &val); + if (error) + return error; + + mutex_lock(&ts->mutex); + + if (!ts->suspended && ts->opened) { + if (val) { + if (!ts->disabled) + __tsc2005_disable(ts); + } else { + if (ts->disabled) + __tsc2005_enable(ts); + } + } + + ts->disabled = !!val; + + mutex_unlock(&ts->mutex); + + return count; +} +static DEVICE_ATTR(disable, 0664, tsc2005_disable_show, tsc2005_disable_store); + static ssize_t tsc2005_selftest_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -466,6 +509,7 @@ out: static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL); static struct attribute *tsc2005_attrs[] = { + &dev_attr_disable.attr, &dev_attr_selftest.attr, NULL }; @@ -551,7 +595,7 @@ static int tsc2005_open(struct input_dev *input) mutex_lock(&ts->mutex); - if (!ts->suspended) + if (!ts->suspended && !ts->disabled) __tsc2005_enable(ts); ts->opened = true; @@ -567,7 +611,7 @@ static void tsc2005_close(struct input_dev *input) mutex_lock(&ts->mutex); - if (!ts->suspended) + if (!ts->suspended && !ts->disabled) __tsc2005_disable(ts); ts->opened = false; @@ -781,7 +825,7 @@ static int tsc2005_suspend(struct device *dev) mutex_lock(&ts->mutex); - if (!ts->suspended && ts->opened) + if (!ts->suspended && !ts->disabled && ts->opened) __tsc2005_disable(ts); ts->suspended = true; @@ -798,7 +842,7 @@ static int tsc2005_resume(struct device *dev) mutex_lock(&ts->mutex); - if (ts->suspended && ts->opened) + if (ts->suspended && !ts->disabled && ts->opened) __tsc2005_enable(ts); ts->suspended = false;