public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: David Brownell <dbrownell@users.sourceforge.net>,
	linux-omap@vger.kernel.org
Subject: [PATCH 09/11] ARM: OMAP: minor gpio bugfixes
Date: Fri, 28 Nov 2008 17:10:50 -0800	[thread overview]
Message-ID: <20081129011050.12337.46685.stgit@localhost> (raw)
In-Reply-To: <20081129010728.12337.8217.stgit@localhost>

From: David Brownell <dbrownell@users.sourceforge.net>

Minor GPIO fixes:

 - If get_gpio_bank() fails, then BUG() out.

 - In omap_set_gpio_debounce():
    * protect the read/modify/write with the relevant spinlock
    * make the omap3 clock ops pass "sparse" checking

Except for the spinlock problem, these were reported through "make".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/gpio.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index e8aae2a..07b6968 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -245,6 +245,8 @@ static inline struct gpio_bank *get_gpio_bank(int gpio)
 		return &gpio_bank[gpio >> 5];
 	if (cpu_is_omap34xx())
 		return &gpio_bank[gpio >> 5];
+	BUG();
+	return NULL;
 }
 
 static inline int get_gpio_index(int gpio)
@@ -448,6 +450,7 @@ void omap_set_gpio_debounce(int gpio, int enable)
 {
 	struct gpio_bank *bank;
 	void __iomem *reg;
+	unsigned long flags;
 	u32 val, l = 1 << get_gpio_index(gpio);
 
 	if (cpu_class_is_omap1())
@@ -455,21 +458,28 @@ void omap_set_gpio_debounce(int gpio, int enable)
 
 	bank = get_gpio_bank(gpio);
 	reg = bank->base;
-
 	reg += OMAP24XX_GPIO_DEBOUNCE_EN;
+
+	spin_lock_irqsave(&bank->lock, flags);
 	val = __raw_readl(reg);
 
 	if (enable && !(val & l))
 		val |= l;
-	else if (!enable && val & l)
+	else if (!enable && (val & l))
 		val &= ~l;
 	else
-		return;
+		goto done;
 
-	if (cpu_is_omap34xx())
-		enable ? clk_enable(bank->dbck) : clk_disable(bank->dbck);
+	if (cpu_is_omap34xx()) {
+		if (enable)
+			clk_enable(bank->dbck);
+		else
+			clk_disable(bank->dbck);
+	}
 
 	__raw_writel(val, reg);
+done:
+	spin_unlock_irqrestore(&bank->lock, flags);
 }
 EXPORT_SYMBOL(omap_set_gpio_debounce);
 


  parent reply	other threads:[~2008-11-29  1:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-29  1:09 [PATCH 00/11] Omap gpio updates for review for 2.6.29 merge window Tony Lindgren
2008-11-29  1:09 ` [PATCH 01/11] ARM: OMAP: Enable GPIO debounce clock only when debounce is enabled v3 Tony Lindgren
2008-11-29  1:09 ` [PATCH 02/11] ARM: OMAP: Extend gpio label column width in omap_gpio debugfs file Tony Lindgren
2008-11-29  1:10 ` [PATCH 03/11] ARM: OMAP: gpios implement new to_irq() Tony Lindgren
2008-11-29  1:10 ` [PATCH 04/11] ARM: OMAP: switch to standard gpio get/set calls Tony Lindgren
2008-11-29  1:10 ` [PATCH 05/11] ARM: OMAP: switch to gpio_direction_input Tony Lindgren
2008-11-29  1:10 ` [PATCH 06/11] ARM: OMAP: switch to gpio_direction_output Tony Lindgren
2008-11-29  1:10 ` [PATCH 07/11] ARM: OMAP: use gpio_to_irq Tony Lindgren
2008-11-29  1:10 ` [PATCH 08/11] ARM: OMAP: make legacy gpio request/free calls superfluous Tony Lindgren
2008-11-29  1:10 ` Tony Lindgren [this message]
2008-11-29  1:10 ` [PATCH 10/11] ARM: OMAP: Switch to gpio_request/free calls Tony Lindgren
2008-12-09  1:29   ` [PATCH 10/11] ARM: OMAP: Switch to gpio_request/free calls, v2 Tony Lindgren
2008-11-29  1:11 ` [PATCH 11/11] ARM: OMAP: Switch ohci-omap to gpio_request/free calls Tony Lindgren
2008-11-29  1:35   ` David Brownell

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=20081129011050.12337.46685.stgit@localhost \
    --to=tony@atomide.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox