brcm2708: update against latest rpi-3.10.y branch
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0153-bcm2708-fix-gpio_to_irq-name-clash.patch
1 From 5342341058c0706fe56a05ebd473fd38ca8654a9 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/174] 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 --- a/arch/arm/mach-bcm2708/bcm2708_gpio.c
22 +++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
23 @@ -135,9 +135,9 @@ static void bcm2708_gpio_set(struct gpio
24  
25  #if BCM_GPIO_USE_IRQ
26  
27 -static int bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
28 +static int bcm2708___bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
29  {
30 -       return gpio_to_irq(gpio);
31 +       return __bcm2708_gpio_to_irq(gpio);
32  }
33  
34  static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
35 @@ -149,15 +149,15 @@ static int bcm2708_gpio_irq_set_type(str
36                 return -EINVAL;
37  
38         if (type & IRQ_TYPE_EDGE_RISING) {
39 -               gpio->rising |= (1 << irq_to_gpio(irq));
40 +               gpio->rising |= (1 << __bcm2708_irq_to_gpio(irq));
41         } else {
42 -               gpio->rising &= ~(1 << irq_to_gpio(irq));
43 +               gpio->rising &= ~(1 << __bcm2708_irq_to_gpio(irq));
44         }
45  
46         if (type & IRQ_TYPE_EDGE_FALLING) {
47 -               gpio->falling |= (1 << irq_to_gpio(irq));
48 +               gpio->falling |= (1 << __bcm2708_irq_to_gpio(irq));
49         } else {
50 -               gpio->falling &= ~(1 << irq_to_gpio(irq));
51 +               gpio->falling &= ~(1 << __bcm2708_irq_to_gpio(irq));
52         }
53         return 0;
54  }
55 @@ -166,7 +166,7 @@ static void bcm2708_gpio_irq_mask(struct
56  {
57         unsigned irq = d->irq;
58         struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
59 -       unsigned gn = irq_to_gpio(irq);
60 +       unsigned gn = __bcm2708_irq_to_gpio(irq);
61         unsigned gb = gn / 32;
62         unsigned long rising = readl(gpio->base + GPIOREN(gb));
63         unsigned long falling = readl(gpio->base + GPIOFEN(gb));
64 @@ -181,7 +181,7 @@ static void bcm2708_gpio_irq_unmask(stru
65  {
66         unsigned irq = d->irq;
67         struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
68 -       unsigned gn = irq_to_gpio(irq);
69 +       unsigned gn = __bcm2708_irq_to_gpio(irq);
70         unsigned gb = gn / 32;
71         unsigned long rising = readl(gpio->base + GPIOREN(gb));
72         unsigned long falling = readl(gpio->base + GPIOFEN(gb));
73 @@ -222,7 +222,7 @@ static irqreturn_t bcm2708_gpio_interrup
74                 edsr = readl(__io_address(GPIO_BASE) + GPIOEDS(bank));
75                 for_each_set_bit(i, &edsr, 32) {
76                         gpio = i + bank * 32;
77 -                       generic_handle_irq(gpio_to_irq(gpio));
78 +                       generic_handle_irq(__bcm2708_gpio_to_irq(gpio));
79                 }
80                 writel(0xffffffff, __io_address(GPIO_BASE) + GPIOEDS(bank));
81         }
82 @@ -239,7 +239,7 @@ static void bcm2708_gpio_irq_init(struct
83  {
84         unsigned irq;
85  
86 -       ucb->gc.to_irq = bcm2708_gpio_to_irq;
87 +       ucb->gc.to_irq = bcm2708___bcm2708_gpio_to_irq;
88  
89         for (irq = GPIO_IRQ_START; irq < (GPIO_IRQ_START + GPIO_IRQS); irq++) {
90                 irq_set_chip_data(irq, ucb);
91 --- a/arch/arm/mach-bcm2708/include/mach/gpio.h
92 +++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
93 @@ -11,8 +11,8 @@
94  
95  #define ARCH_NR_GPIOS 54 // number of gpio lines
96  
97 -#define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
98 -#define irq_to_gpio(x) ((x) - GPIO_IRQ_START)
99 +#define __bcm2708_gpio_to_irq(x)   ((x) + GPIO_IRQ_START)
100 +#define __bcm2708_irq_to_gpio(x)   ((x) - GPIO_IRQ_START)
101  
102  #endif
103