aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-16 22:10:37 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-16 23:29:00 -0700
commit8dbcc432c2b4adf4ff7183afc5f2b42276b2a987 (patch)
treef944bc8f99c380c2fe9090a038d4a0ebeb5ea60c /drivers/input
parent99bb892d8a3f4f384d61e5d20499247a7cdd3d74 (diff)
downloadkernel_goldelico_gta04-8dbcc432c2b4adf4ff7183afc5f2b42276b2a987.zip
kernel_goldelico_gta04-8dbcc432c2b4adf4ff7183afc5f2b42276b2a987.tar.gz
kernel_goldelico_gta04-8dbcc432c2b4adf4ff7183afc5f2b42276b2a987.tar.bz2
Input: tsc2005 - hide selftest attribute if we can't reset
If implementation to perform self-test/reset has not been provided by the platform code hide 'selftest' sysfs attribute instead of returning error when someone tries to use it. Tested-by: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/tsc2005.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index de170e9..bc7e2f9 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -411,13 +411,6 @@ static ssize_t tsc2005_selftest_show(struct device *dev,
u16 temp_high_test;
unsigned int result;
- if (!ts->set_reset) {
- dev_warn(&ts->spi->dev,
- "unable to selftest: no reset function\n");
- result = 0;
- goto out;
- }
-
mutex_lock(&ts->mutex);
/*
@@ -451,11 +444,38 @@ static ssize_t tsc2005_selftest_show(struct device *dev,
mutex_unlock(&ts->mutex);
-out:
return sprintf(buf, "%u\n", result);
}
+
static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL);
+static struct attribute *tsc2005_attrs[] = {
+ &dev_attr_disable.attr,
+ &dev_attr_selftest.attr,
+ NULL
+};
+
+static mode_t tsc2005_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct spi_device *spi = to_spi_device(dev);
+ struct tsc2005 *ts = spi_get_drvdata(spi);
+ mode_t mode = attr->mode;
+
+ if (attr == &dev_attr_selftest.attr) {
+ if (!ts->set_reset)
+ mode = 0;
+ }
+
+ return mode;
+}
+
+static const struct attribute_group tsc2005_attr_group = {
+ .is_visible = tsc2005_attr_is_visible,
+ .attrs = tsc2005_attrs,
+};
+
static void tsc2005_esd_timer(unsigned long data)
{
struct tsc2005 *ts = (struct tsc2005 *)data;
@@ -495,16 +515,6 @@ out:
mutex_unlock(&ts->mutex);
}
-static struct attribute *tsc2005_attrs[] = {
- &dev_attr_disable.attr,
- &dev_attr_selftest.attr,
- NULL
-};
-
-static struct attribute_group tsc2005_attr_group = {
- .attrs = tsc2005_attrs,
-};
-
static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts)
{
tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, 0);