aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@nokia.com>2011-03-24 02:48:19 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-24 02:50:36 -0400
commita0fa2206f550066d6948d43c5401e973e5f7d320 (patch)
tree48afd4cf19e8b552e9f0a2c68eea87e4b662a680 /drivers/input
parent903427955b9ffe1ca4b76c510089774c3b7a4a8a (diff)
Input: tsc2005 - fix locking issue
Commit 0b950d3 (Input: tsc2005 - add open/close) introduced a locking issue with the ESD watchdog: __tsc2005_disable() is calling cancel_delayed_work_sync() with mutex held, and the work also needs the same mutex. Fix the problem by using mutex_trylock() in tsc2005_esd_work(). If the mutex is taken, we know we are in the middle of disable or enable and the watchdog check can be skipped. Signed-off-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.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 2a9a7260fe8e..cbf0ff322676 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -477,7 +477,14 @@ static void tsc2005_esd_work(struct work_struct *work)
477 int error; 477 int error;
478 u16 r; 478 u16 r;
479 479
480 mutex_lock(&ts->mutex); 480 if (!mutex_trylock(&ts->mutex)) {
481 /*
482 * If the mutex is taken, it means that disable or enable is in
483 * progress. In that case just reschedule the work. If the work
484 * is not needed, it will be canceled by disable.
485 */
486 goto reschedule;
487 }
481 488
482 if (time_is_after_jiffies(ts->last_valid_interrupt + 489 if (time_is_after_jiffies(ts->last_valid_interrupt +
483 msecs_to_jiffies(ts->esd_timeout))) 490 msecs_to_jiffies(ts->esd_timeout)))
@@ -510,11 +517,12 @@ static void tsc2005_esd_work(struct work_struct *work)
510 tsc2005_start_scan(ts); 517 tsc2005_start_scan(ts);
511 518
512out: 519out:
520 mutex_unlock(&ts->mutex);
521reschedule:
513 /* re-arm the watchdog */ 522 /* re-arm the watchdog */
514 schedule_delayed_work(&ts->esd_work, 523 schedule_delayed_work(&ts->esd_work,
515 round_jiffies_relative( 524 round_jiffies_relative(
516 msecs_to_jiffies(ts->esd_timeout))); 525 msecs_to_jiffies(ts->esd_timeout)));
517 mutex_unlock(&ts->mutex);
518} 526}
519 527
520static int tsc2005_open(struct input_dev *input) 528static int tsc2005_open(struct input_dev *input)