LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bryan Wu <cooloney@kernel.org>
To: dtor@mail.ru, akpm@linux-foundation.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michael Hennerich <michael.hennerich@analog.com>,
	Bryan Wu <cooloney@kernel.org>
Subject: [PATCH 1/1] input: AD7877 driver fixup
Date: Thu, 30 Oct 2008 17:46:50 +0800	[thread overview]
Message-ID: <1225360010-20176-1-git-send-email-cooloney@kernel.org> (raw)

From: Michael Hennerich <michael.hennerich@analog.com>

 - Test flag with spinlock hold

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
 drivers/input/touchscreen/ad7877.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index aaf88c9..6615bcd 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -388,10 +388,11 @@ static irqreturn_t ad7877_irq(int irq, void *handle)
 	 * doesn't get issued twice while in work.
 	 */
 
-	if (ts->pending)
-		return IRQ_HANDLED;
-
 	spin_lock_irqsave(&ts->lock, flags);
+	if (ts->pending) {
+		spin_unlock_irqrestore(&ts->lock, flags);
+		return IRQ_HANDLED;
+	}
 	ts->pending = 1;
 	spin_unlock_irqrestore(&ts->lock, flags);
 
@@ -420,10 +421,12 @@ static void ad7877_disable(struct ad7877 *ts)
 {
 	unsigned long flags;
 
-	if (ts->disabled)
+	spin_lock_irqsave(&ts->lock, flags);
+	if (ts->disabled) {
+		spin_unlock_irqrestore(&ts->lock, flags);
 		return;
+	}
 
-	spin_lock_irqsave(&ts->lock, flags);
 	ts->disabled = 1;
 	disable_irq(ts->spi->irq);
 	spin_unlock_irqrestore(&ts->lock, flags);
@@ -443,10 +446,11 @@ static void ad7877_enable(struct ad7877 *ts)
 {
 	unsigned long flags;
 
-	if (!ts->disabled)
-		return;
-
 	spin_lock_irqsave(&ts->lock, flags);
+	if (ts->disabled) {
+		spin_unlock_irqrestore(&ts->lock, flags);
+		return;
+	}
 	ts->disabled = 0;
 	enable_irq(ts->spi->irq);
 	spin_unlock_irqrestore(&ts->lock, flags);
-- 
1.5.6

                 reply	other threads:[~2008-10-30  9:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1225360010-20176-1-git-send-email-cooloney@kernel.org \
    --to=cooloney@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dtor@mail.ru \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --subject='Re: [PATCH 1/1] input: AD7877 driver fixup' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).