From patchwork Wed Mar 23 13:05:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Koskinen, Aaro (Nokia - FI/Espoo)" X-Patchwork-Id: 655541 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2ND8Hkf019805 for ; Wed, 23 Mar 2011 13:08:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932832Ab1CWNIQ (ORCPT ); Wed, 23 Mar 2011 09:08:16 -0400 Received: from smtp.nokia.com ([147.243.128.24]:61145 "EHLO mgw-da01.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932830Ab1CWNIP (ORCPT ); Wed, 23 Mar 2011 09:08:15 -0400 Received: from helruo-dhcp02150.ntc.nokia.com (helruo-dhcp02150.ntc.nokia.com [172.21.21.50]) by mgw-da01.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p2ND88wp024499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Mar 2011 15:08:10 +0200 Date: Wed, 23 Mar 2011 15:05:40 +0200 (EET) From: Aaro Koskinen X-X-Sender: aakoskin@esdhcp041196.research.nokia.com To: Dmitry Torokhov cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] input: tsc2005: fix locking issue In-Reply-To: <20110322154202.GA24772@core.coreip.homeip.net> Message-ID: References: <1300724650-6641-1-git-send-email-aaro.koskinen@nokia.com> <20110322061958.GA7990@core.coreip.homeip.net> <20110322154202.GA24772@core.coreip.homeip.net> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 X-Nokia-AV: Clean Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 23 Mar 2011 13:08:17 +0000 (UTC) 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)))