aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-3.10/0153-bcm2708-fix-gpio_to_irq-name-clash.patch
blob: 1482f1cf9a04e666a1a65d6728cd9a5e7bfd4206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From 5342341058c0706fe56a05ebd473fd38ca8654a9 Mon Sep 17 00:00:00 2001
From: Joerg Faschingbauer <jf@faschingbauer.co.at>
Date: Tue, 7 Jan 2014 13:55:15 +0000
Subject: [PATCH 153/174] bcm2708: fix gpio_to_irq() name clash

<mach/gpio.h> has gpio_to_irq() defined as a macro. the macro is
obviously intended as the direct implementation of that
functionality. unfortunately the gpio subsystem offers a public
function of the same name through <linux/gpio.h>. one has to be very
careful to include <mach/gpio.h> before <linux/gpio.h> - otherwise the
code will compile but only work by chance. board code will certainly
not work - the gpio driver is simply not loaded at that time.

fix the clash by renaming the offending macros from <mach/gpio.h>,
together with their uses.
---
 arch/arm/mach-bcm2708/bcm2708_gpio.c      | 20 ++++++++++----------
 arch/arm/mach-bcm2708/include/mach/gpio.h |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

--- a/arch/arm/mach-bcm2708/bcm2708_gpio.c
+++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
@@ -135,9 +135,9 @@ static void bcm2708_gpio_set(struct gpio
 
 #if BCM_GPIO_USE_IRQ
 
-static int bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
+static int bcm2708___bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
 {
-	return gpio_to_irq(gpio);
+	return __bcm2708_gpio_to_irq(gpio);
 }
 
 static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
@@ -149,15 +149,15 @@ static int bcm2708_gpio_irq_set_type(str
 		return -EINVAL;
 
 	if (type & IRQ_TYPE_EDGE_RISING) {
-		gpio->rising |= (1 << irq_to_gpio(irq));
+		gpio->rising |= (1 << __bcm2708_irq_to_gpio(irq));
 	} else {
-		gpio->rising &= ~(1 << irq_to_gpio(irq));
+		gpio->rising &= ~(1 << __bcm2708_irq_to_gpio(irq));
 	}
 
 	if (type & IRQ_TYPE_EDGE_FALLING) {
-		gpio->falling |= (1 << irq_to_gpio(irq));
+		gpio->falling |= (1 << __bcm2708_irq_to_gpio(irq));
 	} else {
-		gpio->falling &= ~(1 << irq_to_gpio(irq));
+		gpio->falling &= ~(1 << __bcm2708_irq_to_gpio(irq));
 	}
 	return 0;
 }
@@ -166,7 +166,7 @@ static void bcm2708_gpio_irq_mask(struct
 {
 	unsigned irq = d->irq;
 	struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
-	unsigned gn = irq_to_gpio(irq);
+	unsigned gn = __bcm2708_irq_to_gpio(irq);
 	unsigned gb = gn / 32;
 	unsigned long rising = readl(gpio->base + GPIOREN(gb));
 	unsigned long falling = readl(gpio->base + GPIOFEN(gb));
@@ -181,7 +181,7 @@ static void bcm2708_gpio_irq_unmask(stru
 {
 	unsigned irq = d->irq;
 	struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
-	unsigned gn = irq_to_gpio(irq);
+	unsigned gn = __bcm2708_irq_to_gpio(irq);
 	unsigned gb = gn / 32;
 	unsigned long rising = readl(gpio->base + GPIOREN(gb));
 	unsigned long falling = readl(gpio->base + GPIOFEN(gb));
@@ -222,7 +222,7 @@ static irqreturn_t bcm2708_gpio_interrup
 		edsr = readl(__io_address(GPIO_BASE) + GPIOEDS(bank));
 		for_each_set_bit(i, &edsr, 32) {
 			gpio = i + bank * 32;
-			generic_handle_irq(gpio_to_irq(gpio));
+			generic_handle_irq(__bcm2708_gpio_to_irq(gpio));
 		}
 		writel(0xffffffff, __io_address(GPIO_BASE) + GPIOEDS(bank));
 	}
@@ -239,7 +239,7 @@ static void bcm2708_gpio_irq_init(struct
 {
 	unsigned irq;
 
-	ucb->gc.to_irq = bcm2708_gpio_to_irq;
+	ucb->gc.to_irq = bcm2708___bcm2708_gpio_to_irq;
 
 	for (irq = GPIO_IRQ_START; irq < (GPIO_IRQ_START + GPIO_IRQS); irq++) {
 		irq_set_chip_data(irq, ucb);
--- a/arch/arm/mach-bcm2708/include/mach/gpio.h
+++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
@@ -11,8 +11,8 @@
 
 #define ARCH_NR_GPIOS 54 // number of gpio lines
 
-#define gpio_to_irq(x)	((x) + GPIO_IRQ_START)
-#define irq_to_gpio(x)	((x) - GPIO_IRQ_START)
+#define __bcm2708_gpio_to_irq(x)   ((x) + GPIO_IRQ_START)
+#define __bcm2708_irq_to_gpio(x)   ((x) - GPIO_IRQ_START)
 
 #endif