diff mbox

input: tsc2005: fix locking issue

Message ID 1300724650-6641-1-git-send-email-aaro.koskinen@nokia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Koskinen, Aaro (Nokia - FI/Espoo) March 21, 2011, 4:24 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 8742061..3a15587 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -345,7 +345,7 @@  static void __tsc2005_disable(struct tsc2005 *ts)
 	disable_irq(ts->spi->irq);
 	del_timer_sync(&ts->penup_timer);
 
-	cancel_delayed_work_sync(&ts->esd_work);
+	cancel_delayed_work(&ts->esd_work);
 
 	enable_irq(ts->spi->irq);
 }
@@ -479,6 +479,12 @@  static void tsc2005_esd_work(struct work_struct *work)
 
 	mutex_lock(&ts->mutex);
 
+	/* The device has been just closed or suspended. */
+	if (!ts->opened || ts->suspended) {
+		mutex_unlock(&ts->mutex);
+		return;
+	}
+
 	if (time_is_after_jiffies(ts->last_valid_interrupt +
 				  msecs_to_jiffies(ts->esd_timeout)))
 		goto out;
@@ -685,6 +691,7 @@  static int __devexit tsc2005_remove(struct spi_device *spi)
 
 	free_irq(ts->spi->irq, ts);
 	input_unregister_device(ts->idev);
+	cancel_delayed_work_sync(&ts->esd_work);
 	kfree(ts);
 
 	spi_set_drvdata(spi, NULL);