ixp4xx: remove linux 3.10 support
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0153-bcm2708-fix-gpio_to_irq-name-clash.patch
1 From ca0e3a11c5cb7a46a98fbad909250ce81a19f1f8 Mon Sep 17 00:00:00 2001
2 From: Joerg Faschingbauer <jf@faschingbauer.co.at>
3 Date: Tue, 7 Jan 2014 13:55:15 +0000
4 Subject: [PATCH 153/196] bcm2708: fix gpio_to_irq() name clash
5
6 <mach/gpio.h> has gpio_to_irq() defined as a macro. the macro is
7 obviously intended as the direct implementation of that
8 functionality. unfortunately the gpio subsystem offers a public
9 function of the same name through <linux/gpio.h>. one has to be very
10 careful to include <mach/gpio.h> before <linux/gpio.h> - otherwise the
11 code will compile but only work by chance. board code will certainly
12 not work - the gpio driver is simply not loaded at that time.
13
14 fix the clash by renaming the offending macros from <mach/gpio.h>,
15 together with their uses.
16 ---
17  arch/arm/mach-bcm2708/bcm2708_gpio.c      | 20 ++++++++++----------
18  arch/arm/mach-bcm2708/include/mach/gpio.h |  4 ++--
19  2 files changed, 12 insertions(+), 12 deletions(-)
20
21 diff --git a/arch/arm/mach-bcm2708/bcm2708_gpio.c b/arch/arm/mach-bcm2708/bcm2708_gpio.c
22 index d0339eb..96fae74 100644
23 --- a/arch/arm/mach-bcm2708/bcm2708_gpio.c
24 +++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
25 @@ -135,9 +135,9 @@ static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
26  
27  #if BCM_GPIO_USE_IRQ
28  
29 -static int bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
30 +static int bcm2708___bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
31  {
32 -       return gpio_to_irq(gpio);
33 +       return __bcm2708_gpio_to_irq(gpio);
34  }
35  
36  static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
37 @@ -149,15 +149,15 @@ static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
38                 return -EINVAL;
39  
40         if (type & IRQ_TYPE_EDGE_RISING) {
41 -               gpio->rising |= (1 << irq_to_gpio(irq));
42 +               gpio->rising |= (1 << __bcm2708_irq_to_gpio(irq));
43         } else {
44 -               gpio->rising &= ~(1 << irq_to_gpio(irq));
45 +               gpio->rising &= ~(1 << __bcm2708_irq_to_gpio(irq));
46         }
47  
48         if (type & IRQ_TYPE_EDGE_FALLING) {
49 -               gpio->falling |= (1 << irq_to_gpio(irq));
50 +               gpio->falling |= (1 << __bcm2708_irq_to_gpio(irq));
51         } else {
52 -               gpio->falling &= ~(1 << irq_to_gpio(irq));
53 +               gpio->falling &= ~(1 << __bcm2708_irq_to_gpio(irq));
54         }
55         return 0;
56  }
57 @@ -166,7 +166,7 @@ static void bcm2708_gpio_irq_mask(struct irq_data *d)
58  {
59         unsigned irq = d->irq;
60         struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
61 -       unsigned gn = irq_to_gpio(irq);
62 +       unsigned gn = __bcm2708_irq_to_gpio(irq);
63         unsigned gb = gn / 32;
64         unsigned long rising = readl(gpio->base + GPIOREN(gb));
65         unsigned long falling = readl(gpio->base + GPIOFEN(gb));
66 @@ -181,7 +181,7 @@ static void bcm2708_gpio_irq_unmask(struct irq_data *d)
67  {
68         unsigned irq = d->irq;
69         struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
70 -       unsigned gn = irq_to_gpio(irq);
71 +       unsigned gn = __bcm2708_irq_to_gpio(irq);
72         unsigned gb = gn / 32;
73         unsigned long rising = readl(gpio->base + GPIOREN(gb));
74         unsigned long falling = readl(gpio->base + GPIOFEN(gb));
75 @@ -222,7 +222,7 @@ static irqreturn_t bcm2708_gpio_interrupt(int irq, void *dev_id)
76                 edsr = readl(__io_address(GPIO_BASE) + GPIOEDS(bank));
77                 for_each_set_bit(i, &edsr, 32) {
78                         gpio = i + bank * 32;
79 -                       generic_handle_irq(gpio_to_irq(gpio));
80 +                       generic_handle_irq(__bcm2708_gpio_to_irq(gpio));
81                 }
82                 writel(0xffffffff, __io_address(GPIO_BASE) + GPIOEDS(bank));
83         }
84 @@ -239,7 +239,7 @@ static void bcm2708_gpio_irq_init(struct bcm2708_gpio *ucb)
85  {
86         unsigned irq;
87  
88 -       ucb->gc.to_irq = bcm2708_gpio_to_irq;
89 +       ucb->gc.to_irq = bcm2708___bcm2708_gpio_to_irq;
90  
91         for (irq = GPIO_IRQ_START; irq < (GPIO_IRQ_START + GPIO_IRQS); irq++) {
92                 irq_set_chip_data(irq, ucb);
93 diff --git a/arch/arm/mach-bcm2708/include/mach/gpio.h b/arch/arm/mach-bcm2708/include/mach/gpio.h
94 index f600bc7..f09639a 100644
95 --- a/arch/arm/mach-bcm2708/include/mach/gpio.h
96 +++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
97 @@ -11,8 +11,8 @@
98  
99  #define ARCH_NR_GPIOS 54 // number of gpio lines
100  
101 -#define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
102 -#define irq_to_gpio(x) ((x) - GPIO_IRQ_START)
103 +#define __bcm2708_gpio_to_irq(x)   ((x) + GPIO_IRQ_START)
104 +#define __bcm2708_irq_to_gpio(x)   ((x) - GPIO_IRQ_START)
105  
106  #endif
107  
108 -- 
109 1.9.1
110