From 456d9950b9861853b75f75a55e7e17b4244f2572 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 23 Mar 2011 23:48:19 -0700 Subject: [PATCH] --- yaml --- r: 242557 b: refs/heads/master c: a0fa2206f550066d6948d43c5401e973e5f7d320 h: refs/heads/master i: 242555: 9df6988270e9eef13e3254223cd500ab38788736 v: v3 --- [refs] | 2 +- trunk/drivers/input/touchscreen/tsc2005.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index e6f1e0dbd8b4..45e567031b75 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 903427955b9ffe1ca4b76c510089774c3b7a4a8a +refs/heads/master: a0fa2206f550066d6948d43c5401e973e5f7d320 diff --git a/trunk/drivers/input/touchscreen/tsc2005.c b/trunk/drivers/input/touchscreen/tsc2005.c index 2a9a7260fe8e..cbf0ff322676 100644 --- a/trunk/drivers/input/touchscreen/tsc2005.c +++ b/trunk/drivers/input/touchscreen/tsc2005.c @@ -477,7 +477,14 @@ static void tsc2005_esd_work(struct work_struct *work) int error; u16 r; - mutex_lock(&ts->mutex); + if (!mutex_trylock(&ts->mutex)) { + /* + * If the mutex is taken, it means that disable or enable is in + * progress. In that case just reschedule the work. If the work + * is not needed, it will be canceled by disable. + */ + goto reschedule; + } if (time_is_after_jiffies(ts->last_valid_interrupt + msecs_to_jiffies(ts->esd_timeout))) @@ -510,11 +517,12 @@ static void tsc2005_esd_work(struct work_struct *work) tsc2005_start_scan(ts); out: + mutex_unlock(&ts->mutex); +reschedule: /* re-arm the watchdog */ schedule_delayed_work(&ts->esd_work, round_jiffies_relative( msecs_to_jiffies(ts->esd_timeout))); - mutex_unlock(&ts->mutex); } static int tsc2005_open(struct input_dev *input)