diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-17 01:10:37 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-03-17 02:29:00 -0400 |
commit | 8dbcc432c2b4adf4ff7183afc5f2b42276b2a987 (patch) | |
tree | f944bc8f99c380c2fe9090a038d4a0ebeb5ea60c /drivers | |
parent | 99bb892d8a3f4f384d61e5d20499247a7cdd3d74 (diff) |
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')
-rw-r--r-- | drivers/input/touchscreen/tsc2005.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c index de170e9dc54a..bc7e2f974b7e 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, | |||
411 | u16 temp_high_test; | 411 | u16 temp_high_test; |
412 | unsigned int result; | 412 | unsigned int result; |
413 | 413 | ||
414 | if (!ts->set_reset) { | ||
415 | dev_warn(&ts->spi->dev, | ||
416 | "unable to selftest: no reset function\n"); | ||
417 | result = 0; | ||
418 | goto out; | ||
419 | } | ||
420 | |||
421 | mutex_lock(&ts->mutex); | 414 | mutex_lock(&ts->mutex); |
422 | 415 | ||
423 | /* | 416 | /* |
@@ -451,11 +444,38 @@ static ssize_t tsc2005_selftest_show(struct device *dev, | |||
451 | 444 | ||
452 | mutex_unlock(&ts->mutex); | 445 | mutex_unlock(&ts->mutex); |
453 | 446 | ||
454 | out: | ||
455 | return sprintf(buf, "%u\n", result); | 447 | return sprintf(buf, "%u\n", result); |
456 | } | 448 | } |
449 | |||
457 | static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL); | 450 | static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL); |
458 | 451 | ||
452 | static struct attribute *tsc2005_attrs[] = { | ||
453 | &dev_attr_disable.attr, | ||
454 | &dev_attr_selftest.attr, | ||
455 | NULL | ||
456 | }; | ||
457 | |||
458 | static mode_t tsc2005_attr_is_visible(struct kobject *kobj, | ||
459 | struct attribute *attr, int n) | ||
460 | { | ||
461 | struct device *dev = container_of(kobj, struct device, kobj); | ||
462 | struct spi_device *spi = to_spi_device(dev); | ||
463 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
464 | mode_t mode = attr->mode; | ||
465 | |||
466 | if (attr == &dev_attr_selftest.attr) { | ||
467 | if (!ts->set_reset) | ||
468 | mode = 0; | ||
469 | } | ||
470 | |||
471 | return mode; | ||
472 | } | ||
473 | |||
474 | static const struct attribute_group tsc2005_attr_group = { | ||
475 | .is_visible = tsc2005_attr_is_visible, | ||
476 | .attrs = tsc2005_attrs, | ||
477 | }; | ||
478 | |||
459 | static void tsc2005_esd_timer(unsigned long data) | 479 | static void tsc2005_esd_timer(unsigned long data) |
460 | { | 480 | { |
461 | struct tsc2005 *ts = (struct tsc2005 *)data; | 481 | struct tsc2005 *ts = (struct tsc2005 *)data; |
@@ -495,16 +515,6 @@ out: | |||
495 | mutex_unlock(&ts->mutex); | 515 | mutex_unlock(&ts->mutex); |
496 | } | 516 | } |
497 | 517 | ||
498 | static struct attribute *tsc2005_attrs[] = { | ||
499 | &dev_attr_disable.attr, | ||
500 | &dev_attr_selftest.attr, | ||
501 | NULL | ||
502 | }; | ||
503 | |||
504 | static struct attribute_group tsc2005_attr_group = { | ||
505 | .attrs = tsc2005_attrs, | ||
506 | }; | ||
507 | |||
508 | static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts) | 518 | static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts) |
509 | { | 519 | { |
510 | tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, 0); | 520 | tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, 0); |