diff mbox

input: tsc2005: fix locking issue

Message ID alpine.DEB.1.10.1103231452530.2634@esdhcp041196.research.nokia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Koskinen, Aaro (Nokia - FI/Espoo) March 23, 2011, 1:05 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 03e4968..cf244be 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -477,7 +477,17 @@  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.
+		 */
+		schedule_delayed_work(&ts->esd_work,
+			round_jiffies_relative(
+				msecs_to_jiffies(ts->esd_timeout)));
+		return;
+	}

  	if (time_is_after_jiffies(ts->last_valid_interrupt +
  				  msecs_to_jiffies(ts->esd_timeout)))