From patchwork Sat Aug 21 05:59:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 121461 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7L5tebi026895 for ; Sat, 21 Aug 2010 05:55:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751278Ab0HUFzk (ORCPT ); Sat, 21 Aug 2010 01:55:40 -0400 Received: from mail.windriver.com ([147.11.1.11]:64431 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751102Ab0HUFzk (ORCPT ); Sat, 21 Aug 2010 01:55:40 -0400 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.windriver.com (8.14.3/8.14.3) with ESMTP id o7L5tXt7019614; Fri, 20 Aug 2010 22:55:34 -0700 (PDT) Received: from localhost.localdomain ([128.224.163.220]) by ALA-MAIL03.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 20 Aug 2010 22:55:32 -0700 From: Jason Wang To: dmitry.torokhov@gmail.com, dtor@mail.ru, notasas@gmail.com, vapier@gentoo.org Cc: linux-input@vger.kernel.org Subject: [PATCH v2] Input: ads7846 - Replace spinlock by mutex to wrap disable()/enable() Date: Sat, 21 Aug 2010 13:59:00 +0800 Message-Id: <1282370340-3157-1-git-send-email-jason77.wang@gmail.com> X-Mailer: git-send-email 1.5.6.5 X-OriginalArrivalTime: 21 Aug 2010 05:55:33.0110 (UTC) FILETIME=[77CA4160:01CB40F5] 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.3 (demeter.kernel.org [140.211.167.41]); Sat, 21 Aug 2010 05:55:41 +0000 (UTC) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 1603193..0b875fa 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -130,6 +130,7 @@ struct ads7846 { unsigned irq_disabled:1; /* P: lock */ unsigned disabled:1; unsigned is_suspended:1; + struct mutex mutex; int (*filter)(void *data, int data_idx, int *val); void *filter_data; @@ -531,14 +532,14 @@ static ssize_t ads7846_disable_store(struct device *dev, if (strict_strtoul(buf, 10, &i)) return -EINVAL; - spin_lock_irq(&ts->lock); + mutex_lock(&ts->mutex); if (i) ads7846_disable(ts); else ads7846_enable(ts); - spin_unlock_irq(&ts->lock); + mutex_unlock(&ts->mutex); return count; } @@ -848,11 +849,8 @@ static void ads7846_disable(struct ads7846 *ts) /* the timer will run at least once more, and * leave everything in a clean state, IRQ disabled */ - while (ts->pending) { - spin_unlock_irq(&ts->lock); + while (ts->pending) msleep(1); - spin_lock_irq(&ts->lock); - } } regulator_disable(ts->reg); @@ -879,12 +877,12 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message) { struct ads7846 *ts = dev_get_drvdata(&spi->dev); - spin_lock_irq(&ts->lock); + mutex_lock(&ts->mutex); ts->is_suspended = 1; ads7846_disable(ts); - spin_unlock_irq(&ts->lock); + mutex_unlock(&ts->mutex); if (device_may_wakeup(&ts->spi->dev)) enable_irq_wake(ts->spi->irq); @@ -900,12 +898,12 @@ static int ads7846_resume(struct spi_device *spi) if (device_may_wakeup(&ts->spi->dev)) disable_irq_wake(ts->spi->irq); - spin_lock_irq(&ts->lock); + mutex_lock(&ts->mutex); ts->is_suspended = 0; ads7846_enable(ts); - spin_unlock_irq(&ts->lock); + mutex_unlock(&ts->mutex); return 0; } @@ -999,6 +997,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) ts->timer.function = ads7846_timer; spin_lock_init(&ts->lock); + mutex_init(&ts->mutex); ts->model = pdata->model ? : 7846; ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;