From: Pavel Machek <pavel@ucw.cz>
To: pali.rohar@gmail.com, sre@debian.org, sre@ring0.de,
kernel list <linux-kernel@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
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
Date: Sun, 9 Nov 2014 12:56:37 +0100 [thread overview]
Message-ID: <20141109115636.GA3106@amd> (raw)
Implement disable attribute for tsc2005 touchscreen. It is useful to
avoid wakeups when phone is in the pocket.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
[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;
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
WARNING: multiple messages have this Message-ID (diff)
From: pavel@ucw.cz (Pavel Machek)
To: linux-arm-kernel@lists.infradead.org
Subject: tsc2005 touchscreen: implement disable attribute
Date: Sun, 9 Nov 2014 12:56:37 +0100 [thread overview]
Message-ID: <20141109115636.GA3106@amd> (raw)
Implement disable attribute for tsc2005 touchscreen. It is useful to
avoid wakeups when phone is in the pocket.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
[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;
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next reply other threads:[~2014-11-09 11:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 11:56 Pavel Machek [this message]
2014-11-09 11:56 ` tsc2005 touchscreen: implement disable attribute Pavel Machek
2014-11-09 12:40 ` Sebastian Reichel
2014-11-09 12:40 ` Sebastian Reichel
2014-11-09 12:49 ` Pali Rohár
2014-11-09 12:49 ` Pali Rohár
2014-11-09 20:01 ` Dmitry Torokhov
2014-11-09 20:01 ` Dmitry Torokhov
2014-11-09 20:01 ` Dmitry Torokhov
2014-11-10 9:14 ` Pali Rohár
2014-11-10 9:14 ` Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141109115636.GA3106@amd \
--to=pavel@ucw.cz \
--cc=B38611@freescale.com \
--cc=aaro.koskinen@iki.fi \
--cc=freemangordon@abv.bg \
--cc=jg1.han@samsung.com \
--cc=khilman@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=pali.rohar@gmail.com \
--cc=sre@debian.org \
--cc=sre@ring0.de \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.