Skip to content

Commit e598700

Browse files
jfaschpopcornmix
authored andcommitted
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.
1 parent 639f74a commit e598700

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

arch/arm/mach-bcm2708/bcm2708_gpio.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
135135

136136
#if BCM_GPIO_USE_IRQ
137137

138-
static int bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
138+
static int bcm2708___bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
139139
{
140-
return gpio_to_irq(gpio);
140+
return __bcm2708_gpio_to_irq(gpio);
141141
}
142142

143143
static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
@@ -149,15 +149,15 @@ static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
149149
return -EINVAL;
150150

151151
if (type & IRQ_TYPE_EDGE_RISING) {
152-
gpio->rising |= (1 << irq_to_gpio(irq));
152+
gpio->rising |= (1 << __bcm2708_irq_to_gpio(irq));
153153
} else {
154-
gpio->rising &= ~(1 << irq_to_gpio(irq));
154+
gpio->rising &= ~(1 << __bcm2708_irq_to_gpio(irq));
155155
}
156156

157157
if (type & IRQ_TYPE_EDGE_FALLING) {
158-
gpio->falling |= (1 << irq_to_gpio(irq));
158+
gpio->falling |= (1 << __bcm2708_irq_to_gpio(irq));
159159
} else {
160-
gpio->falling &= ~(1 << irq_to_gpio(irq));
160+
gpio->falling &= ~(1 << __bcm2708_irq_to_gpio(irq));
161161
}
162162
return 0;
163163
}
@@ -166,7 +166,7 @@ static void bcm2708_gpio_irq_mask(struct irq_data *d)
166166
{
167167
unsigned irq = d->irq;
168168
struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
169-
unsigned gn = irq_to_gpio(irq);
169+
unsigned gn = __bcm2708_irq_to_gpio(irq);
170170
unsigned gb = gn / 32;
171171
unsigned long rising = readl(gpio->base + GPIOREN(gb));
172172
unsigned long falling = readl(gpio->base + GPIOFEN(gb));
@@ -181,7 +181,7 @@ static void bcm2708_gpio_irq_unmask(struct irq_data *d)
181181
{
182182
unsigned irq = d->irq;
183183
struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
184-
unsigned gn = irq_to_gpio(irq);
184+
unsigned gn = __bcm2708_irq_to_gpio(irq);
185185
unsigned gb = gn / 32;
186186
unsigned long rising = readl(gpio->base + GPIOREN(gb));
187187
unsigned long falling = readl(gpio->base + GPIOFEN(gb));
@@ -222,7 +222,7 @@ static irqreturn_t bcm2708_gpio_interrupt(int irq, void *dev_id)
222222
edsr = readl(__io_address(GPIO_BASE) + GPIOEDS(bank));
223223
for_each_set_bit(i, &edsr, 32) {
224224
gpio = i + bank * 32;
225-
generic_handle_irq(gpio_to_irq(gpio));
225+
generic_handle_irq(__bcm2708_gpio_to_irq(gpio));
226226
}
227227
writel(0xffffffff, __io_address(GPIO_BASE) + GPIOEDS(bank));
228228
}
@@ -239,7 +239,7 @@ static void bcm2708_gpio_irq_init(struct bcm2708_gpio *ucb)
239239
{
240240
unsigned irq;
241241

242-
ucb->gc.to_irq = bcm2708_gpio_to_irq;
242+
ucb->gc.to_irq = bcm2708___bcm2708_gpio_to_irq;
243243

244244
for (irq = GPIO_IRQ_START; irq < (GPIO_IRQ_START + GPIO_IRQS); irq++) {
245245
irq_set_chip_data(irq, ucb);

arch/arm/mach-bcm2708/include/mach/gpio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define ARCH_NR_GPIOS 54 // number of gpio lines
1313

14-
#define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
15-
#define irq_to_gpio(x) ((x) - GPIO_IRQ_START)
14+
#define __bcm2708_gpio_to_irq(x) ((x) + GPIO_IRQ_START)
15+
#define __bcm2708_irq_to_gpio(x) ((x) - GPIO_IRQ_START)
1616

1717
#endif

0 commit comments

Comments
 (0)