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>
This commit is contained in:
parent
903427955b
commit
a0fa2206f5
|
@ -477,7 +477,14 @@ static void tsc2005_esd_work(struct work_struct *work)
|
||||||
int error;
|
int error;
|
||||||
u16 r;
|
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 +
|
if (time_is_after_jiffies(ts->last_valid_interrupt +
|
||||||
msecs_to_jiffies(ts->esd_timeout)))
|
msecs_to_jiffies(ts->esd_timeout)))
|
||||||
|
@ -510,11 +517,12 @@ static void tsc2005_esd_work(struct work_struct *work)
|
||||||
tsc2005_start_scan(ts);
|
tsc2005_start_scan(ts);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
mutex_unlock(&ts->mutex);
|
||||||
|
reschedule:
|
||||||
/* re-arm the watchdog */
|
/* re-arm the watchdog */
|
||||||
schedule_delayed_work(&ts->esd_work,
|
schedule_delayed_work(&ts->esd_work,
|
||||||
round_jiffies_relative(
|
round_jiffies_relative(
|
||||||
msecs_to_jiffies(ts->esd_timeout)));
|
msecs_to_jiffies(ts->esd_timeout)));
|
||||||
mutex_unlock(&ts->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsc2005_open(struct input_dev *input)
|
static int tsc2005_open(struct input_dev *input)
|
||||||
|
|
Loading…
Reference in New Issue