lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 30 Mar 2007 11:08:46 +0800
From:	"Wu, Bryan" <bryan.wu@...log.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] blackfin arch fix bug interrupt setup problem request_irq:
	set_gpio_dir called before gpio_request


Signed-off-by: Bryan Wu <bryan.wu@...log.com>
---
 arch/blackfin/mach-common/ints-priority-dc.c |   36 +++++++++++++++++++-----
 arch/blackfin/mach-common/ints-priority-sc.c |   38 +++++++++++++++++++++-----
 include/asm-blackfin/gpio.h                  |    6 ++--
 3 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/arch/blackfin/mach-common/ints-priority-dc.c b/arch/blackfin/mach-common/ints-priority-dc.c
index 01fd688..039191c 100644
--- a/arch/blackfin/mach-common/ints-priority-dc.c
+++ b/arch/blackfin/mach-common/ints-priority-dc.c
@@ -217,11 +217,18 @@ static void bf561_gpio_unmask_irq(unsigned int irq)
 static unsigned int bf561_gpio_irq_startup(unsigned int irq)
 {
 	unsigned int ret;
+	u16 gpionr = irq - IRQ_PF0;
+
+	if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
+			
+		ret = gpio_request(gpionr, NULL);
+		if(ret)
+			return ret;
 
-	ret = gpio_request(irq - IRQ_PF0, NULL);
+	}		
 
-	if (!ret)
-	  bf561_gpio_unmask_irq(irq);
+	gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
+	bf561_gpio_unmask_irq(irq);
 
   return ret;
 
@@ -231,15 +238,15 @@ static void bf561_gpio_irq_shutdown(unsigned int irq)
 {
 	bf561_gpio_mask_irq(irq);
 	gpio_free(irq - IRQ_PF0);
+	gpio_enabled[gpio_bank(irq - IRQ_PF0)] &= ~gpio_bit(irq - IRQ_PF0);
 }
 
 static int bf561_gpio_irq_type(unsigned int irq, unsigned int type)
 {
 
+	unsigned int ret;
 	u16 gpionr = irq - IRQ_PF0;
 
-		set_gpio_dir(gpionr, 0);
-		set_gpio_inen(gpionr, 1);
 
 		if (type == IRQ_TYPE_PROBE) {
 			/* only probe unenabled GPIO interrupt lines */
@@ -250,11 +257,26 @@ static int bf561_gpio_irq_type(unsigned int irq, unsigned int type)
 		}
 
 		if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
-			    IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
+			    IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
+
+		if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
+			
+			ret = gpio_request(gpionr, NULL);
+			if(ret)
+				return ret;
+
+		}
 
 			gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
-		else
+		} else {
 			gpio_enabled[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
+			return 0;		
+		}
+
+
+		set_gpio_dir(gpionr, 0);
+		set_gpio_inen(gpionr, 1);
+
 
 		if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
 			gpio_edge_triggered[gpio_bank(gpionr)] |= gpio_bit(gpionr);
diff --git a/arch/blackfin/mach-common/ints-priority-sc.c b/arch/blackfin/mach-common/ints-priority-sc.c
index 8b9e68b..8197a32 100644
--- a/arch/blackfin/mach-common/ints-priority-sc.c
+++ b/arch/blackfin/mach-common/ints-priority-sc.c
@@ -326,11 +326,18 @@ static void bfin_gpio_unmask_irq(unsigned int irq)
 static unsigned int bfin_gpio_irq_startup(unsigned int irq)
 {
 	unsigned int ret;
+	u16 gpionr = irq - IRQ_PF0;
+
+	if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
+			
+		ret = gpio_request(gpionr, NULL);
+		if(ret)
+			return ret;
 
-	ret = gpio_request(irq - IRQ_PF0, NULL);
+	}		
 
-	if (!ret)
-		bfin_gpio_unmask_irq(irq);
+	gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
+	bfin_gpio_unmask_irq(irq);
 
 	return ret;
 }
@@ -339,14 +346,15 @@ static void bfin_gpio_irq_shutdown(unsigned int irq)
 {
 	bfin_gpio_mask_irq(irq);
 	gpio_free(irq - IRQ_PF0);
+	gpio_enabled[gpio_bank(irq - IRQ_PF0)] &= ~gpio_bit(irq - IRQ_PF0);
 }
 
 static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
 {
+
+	unsigned int ret;
 	u16 gpionr = irq - IRQ_PF0;
 
-		set_gpio_dir(gpionr, 0);
-		set_gpio_inen(gpionr, 1);
 
 		if (type == IRQ_TYPE_PROBE) {
 			/* only probe unenabled GPIO interrupt lines */
@@ -357,10 +365,26 @@ static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
 		}
 
 		if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
-			    IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
+			    IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
+
+		if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
+			
+			ret = gpio_request(gpionr, NULL);
+			if(ret)
+				return ret;
+
+		}
+
 			gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
-		else
+		} else {
 			gpio_enabled[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
+			return 0;		
+		}
+
+
+		set_gpio_dir(gpionr, 0);
+		set_gpio_inen(gpionr, 1);
+
 
 		if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
 			gpio_edge_triggered[gpio_bank(gpionr)] |= gpio_bit(gpionr);
diff --git a/include/asm-blackfin/gpio.h b/include/asm-blackfin/gpio.h
index 06dd9cd..14db45f 100644
--- a/include/asm-blackfin/gpio.h
+++ b/include/asm-blackfin/gpio.h
@@ -85,9 +85,9 @@
 #ifndef __ARCH_BLACKFIN_GPIO_H__
 #define __ARCH_BLACKFIN_GPIO_H__
 
-#define gpio_bank(x) (x >> 4)
-#define gpio_bit(x)  (1<<(x & 0xF))
-#define gpio_sub_n(x) (x & 0xF)
+#define gpio_bank(x) ((x) >> 4)
+#define gpio_bit(x)  (1<<((x) & 0xF))
+#define gpio_sub_n(x) ((x) & 0xF)
 
 #define GPIO_BANKSIZE 16
 
-- 
1.5.0.5

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists