diff options
author | Julia Cartwright <julia@ni.com> | 2017-03-09 11:21:49 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-03-16 16:52:06 -0400 |
commit | 21d01c9c081ab231d6ef9d94ad9345c58b6568c1 (patch) | |
tree | d440b4fc169af796d9ed8fd171aa7b2c70a69499 /drivers/gpio/gpio-altera.c | |
parent | 660549e05d6bf7ed7160de51da2948c2f1646f7e (diff) |
gpio: altera: make use of raw_spinlock variants
The altera gpio driver currently implements an irq_chip for handling
interrupts; due to how irq_chip handling is done, it's necessary for the
irq_chip methods to be invoked from hardirq context, even on a a real-time
kernel. Because the spinlock_t type becomes a "sleeping" spinlock w/ RT
kernels, it is not suitable to be used with irq_chips.
A quick audit of the operations under the lock reveal that they do only
minimal, bounded work, and are therefore safe to do under a raw spinlock.
Signed-off-by: Julia Cartwright <julia@ni.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-altera.c')
-rw-r--r-- | drivers/gpio/gpio-altera.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 5bddbd507ca9..6c08d16ea911 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c | |||
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | struct altera_gpio_chip { | 39 | struct altera_gpio_chip { |
40 | struct of_mm_gpio_chip mmchip; | 40 | struct of_mm_gpio_chip mmchip; |
41 | spinlock_t gpio_lock; | 41 | raw_spinlock_t gpio_lock; |
42 | int interrupt_trigger; | 42 | int interrupt_trigger; |
43 | int mapped_irq; | 43 | int mapped_irq; |
44 | }; | 44 | }; |
@@ -53,12 +53,12 @@ static void altera_gpio_irq_unmask(struct irq_data *d) | |||
53 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); | 53 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
54 | mm_gc = &altera_gc->mmchip; | 54 | mm_gc = &altera_gc->mmchip; |
55 | 55 | ||
56 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 56 | raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
57 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 57 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
58 | /* Set ALTERA_GPIO_IRQ_MASK bit to unmask */ | 58 | /* Set ALTERA_GPIO_IRQ_MASK bit to unmask */ |
59 | intmask |= BIT(irqd_to_hwirq(d)); | 59 | intmask |= BIT(irqd_to_hwirq(d)); |
60 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 60 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
61 | spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); | 61 | raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); |
62 | } | 62 | } |
63 | 63 | ||
64 | static void altera_gpio_irq_mask(struct irq_data *d) | 64 | static void altera_gpio_irq_mask(struct irq_data *d) |
@@ -71,12 +71,12 @@ static void altera_gpio_irq_mask(struct irq_data *d) | |||
71 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); | 71 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
72 | mm_gc = &altera_gc->mmchip; | 72 | mm_gc = &altera_gc->mmchip; |
73 | 73 | ||
74 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 74 | raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
75 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 75 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
76 | /* Clear ALTERA_GPIO_IRQ_MASK bit to mask */ | 76 | /* Clear ALTERA_GPIO_IRQ_MASK bit to mask */ |
77 | intmask &= ~BIT(irqd_to_hwirq(d)); | 77 | intmask &= ~BIT(irqd_to_hwirq(d)); |
78 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 78 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
79 | spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); | 79 | raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
@@ -143,14 +143,14 @@ static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value) | |||
143 | mm_gc = to_of_mm_gpio_chip(gc); | 143 | mm_gc = to_of_mm_gpio_chip(gc); |
144 | chip = gpiochip_get_data(gc); | 144 | chip = gpiochip_get_data(gc); |
145 | 145 | ||
146 | spin_lock_irqsave(&chip->gpio_lock, flags); | 146 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
147 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); | 147 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); |
148 | if (value) | 148 | if (value) |
149 | data_reg |= BIT(offset); | 149 | data_reg |= BIT(offset); |
150 | else | 150 | else |
151 | data_reg &= ~BIT(offset); | 151 | data_reg &= ~BIT(offset); |
152 | writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA); | 152 | writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA); |
153 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 153 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
154 | } | 154 | } |
155 | 155 | ||
156 | static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) | 156 | static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) |
@@ -163,12 +163,12 @@ static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) | |||
163 | mm_gc = to_of_mm_gpio_chip(gc); | 163 | mm_gc = to_of_mm_gpio_chip(gc); |
164 | chip = gpiochip_get_data(gc); | 164 | chip = gpiochip_get_data(gc); |
165 | 165 | ||
166 | spin_lock_irqsave(&chip->gpio_lock, flags); | 166 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
167 | /* Set pin as input, assumes software controlled IP */ | 167 | /* Set pin as input, assumes software controlled IP */ |
168 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); | 168 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); |
169 | gpio_ddr &= ~BIT(offset); | 169 | gpio_ddr &= ~BIT(offset); |
170 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); | 170 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); |
171 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 171 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
172 | 172 | ||
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
@@ -184,7 +184,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, | |||
184 | mm_gc = to_of_mm_gpio_chip(gc); | 184 | mm_gc = to_of_mm_gpio_chip(gc); |
185 | chip = gpiochip_get_data(gc); | 185 | chip = gpiochip_get_data(gc); |
186 | 186 | ||
187 | spin_lock_irqsave(&chip->gpio_lock, flags); | 187 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
188 | /* Sets the GPIO value */ | 188 | /* Sets the GPIO value */ |
189 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); | 189 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); |
190 | if (value) | 190 | if (value) |
@@ -197,7 +197,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, | |||
197 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); | 197 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); |
198 | gpio_ddr |= BIT(offset); | 198 | gpio_ddr |= BIT(offset); |
199 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); | 199 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); |
200 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 200 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
201 | 201 | ||
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
@@ -266,7 +266,7 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
266 | if (!altera_gc) | 266 | if (!altera_gc) |
267 | return -ENOMEM; | 267 | return -ENOMEM; |
268 | 268 | ||
269 | spin_lock_init(&altera_gc->gpio_lock); | 269 | raw_spin_lock_init(&altera_gc->gpio_lock); |
270 | 270 | ||
271 | if (of_property_read_u32(node, "altr,ngpio", ®)) | 271 | if (of_property_read_u32(node, "altr,ngpio", ®)) |
272 | /* By default assume maximum ngpio */ | 272 | /* By default assume maximum ngpio */ |