@@ -33,8 +33,6 @@ struct davinci_gpio_regs {
u32 intstat;
};
-static DEFINE_SPINLOCK(gpio_lock);
-
#define chip2controller(chip) \
container_of(chip, struct davinci_gpio_controller, chip)
@@ -84,16 +82,17 @@ static inline int __davinci_direction(struct gpio_chip *chip,
{
struct davinci_gpio_controller *d = chip2controller(chip);
struct davinci_gpio_regs __iomem *g = d->regs;
+ unsigned long flags;
u32 temp;
- spin_lock(&gpio_lock);
+ spin_lock_irqsave(&d->lock, flags);
temp = __raw_readl(&g->dir);
if (out)
temp &= ~(1 << offset);
else
temp |= (1 << offset);
__raw_writel(temp, &g->dir);
- spin_unlock(&gpio_lock);
+ spin_unlock_irqrestore(&d->lock, flags);
return 0;
}
@@ -173,6 +172,8 @@ static int __init davinci_gpio_setup(void)
if (chips[i].chip.ngpio > 32)
chips[i].chip.ngpio = 32;
+ spin_lock_init(&chips[i].lock);
+
regs = gpio2regs(base);
chips[i].regs = regs;
chips[i].set_data = ®s->set_data;
@@ -14,6 +14,8 @@
#define __DAVINCI_GPIO_H
#include <linux/io.h>
+#include <linux/spinlock.h>
+
#include <asm-generic/gpio.h>
#include <mach/irqs.h>
@@ -51,6 +53,7 @@ enum davinci_gpio_type {
struct davinci_gpio_controller {
struct davinci_gpio_regs __iomem *regs;
+ spinlock_t lock;
struct gpio_chip chip;
int irq_base;
void __iomem *set_data;