All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jason77.wang@gmail.com>
To: dmitry.torokhov@gmail.com, dtor@mail.ru, notasas@gmail.com,
	vapier@gentoo.org
Cc: linux-input@vger.kernel.org
Subject: [PATCH] Input: ads7846 - move regulator codes out of spinlock protected area
Date: Thu, 19 Aug 2010 16:14:30 +0800	[thread overview]
Message-ID: <1282205670-30618-1-git-send-email-jason77.wang@gmail.com> (raw)

The commit 9114337 introduces regulator operations in the ads7846
touchscreen driver. Among these operations, some are called in the
spinlock protected context.
On most platforms, the regulator operation is achieved through
i2c/spi bus transfer operations, some of bus transfer operations will
call wait_for_completion function. It isn't allowable  to call
sleepable function in the atomic context. So move them out from the
atomic context.

[tested on TI OMAP3530EVM board]

Signed-off-by: Jason Wang <jason77.wang@gmail.com>
---
 drivers/input/touchscreen/ads7846.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 1603193..9421df9 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -531,6 +531,9 @@ static ssize_t ads7846_disable_store(struct device *dev,
 	if (strict_strtoul(buf, 10, &i))
 		return -EINVAL;
 
+	if (!i)
+		regulator_enable(ts->reg);
+
 	spin_lock_irq(&ts->lock);
 
 	if (i)
@@ -540,6 +543,9 @@ static ssize_t ads7846_disable_store(struct device *dev,
 
 	spin_unlock_irq(&ts->lock);
 
+	if (i)
+		regulator_disable(ts->reg);
+
 	return count;
 }
 
@@ -855,8 +861,6 @@ static void ads7846_disable(struct ads7846 *ts)
 		}
 	}
 
-	regulator_disable(ts->reg);
-
 	/* we know the chip's in lowpower mode since we always
 	 * leave it that way after every request
 	 */
@@ -868,8 +872,6 @@ static void ads7846_enable(struct ads7846 *ts)
 	if (!ts->disabled)
 		return;
 
-	regulator_enable(ts->reg);
-
 	ts->disabled = 0;
 	ts->irq_disabled = 0;
 	enable_irq(ts->spi->irq);
@@ -886,6 +888,8 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
 
 	spin_unlock_irq(&ts->lock);
 
+	regulator_disable(ts->reg);
+
 	if (device_may_wakeup(&ts->spi->dev))
 		enable_irq_wake(ts->spi->irq);
 
@@ -900,6 +904,8 @@ static int ads7846_resume(struct spi_device *spi)
 	if (device_may_wakeup(&ts->spi->dev))
 		disable_irq_wake(ts->spi->irq);
 
+	regulator_enable(ts->reg);
+
 	spin_lock_irq(&ts->lock);
 
 	ts->is_suspended = 0;
-- 
1.5.6.5


             reply	other threads:[~2010-08-19  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19  8:14 Jason Wang [this message]
2010-08-20  5:19 ` [PATCH] Input: ads7846 - move regulator codes out of spinlock protected area Dmitry Torokhov
2010-08-20  7:19   ` Jason Wang

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=1282205670-30618-1-git-send-email-jason77.wang@gmail.com \
    --to=jason77.wang@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=linux-input@vger.kernel.org \
    --cc=notasas@gmail.com \
    --cc=vapier@gentoo.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.