Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: 104-idio-16: make use of raw_spinlock variants

The 104-idio-16 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>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Julia Cartwright and committed by
Linus Walleij
3906e808 0e3cb6ee

+12 -12
+12 -12
drivers/gpio/gpio-104-idio-16.c
··· 50 50 */ 51 51 struct idio_16_gpio { 52 52 struct gpio_chip chip; 53 - spinlock_t lock; 53 + raw_spinlock_t lock; 54 54 unsigned long irq_mask; 55 55 unsigned base; 56 56 unsigned out_state; ··· 99 99 if (offset > 15) 100 100 return; 101 101 102 - spin_lock_irqsave(&idio16gpio->lock, flags); 102 + raw_spin_lock_irqsave(&idio16gpio->lock, flags); 103 103 104 104 if (value) 105 105 idio16gpio->out_state |= mask; ··· 111 111 else 112 112 outb(idio16gpio->out_state, idio16gpio->base); 113 113 114 - spin_unlock_irqrestore(&idio16gpio->lock, flags); 114 + raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); 115 115 } 116 116 117 117 static void idio_16_gpio_set_multiple(struct gpio_chip *chip, ··· 120 120 struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); 121 121 unsigned long flags; 122 122 123 - spin_lock_irqsave(&idio16gpio->lock, flags); 123 + raw_spin_lock_irqsave(&idio16gpio->lock, flags); 124 124 125 125 idio16gpio->out_state &= ~*mask; 126 126 idio16gpio->out_state |= *mask & *bits; ··· 130 130 if ((*mask >> 8) & 0xFF) 131 131 outb(idio16gpio->out_state >> 8, idio16gpio->base + 4); 132 132 133 - spin_unlock_irqrestore(&idio16gpio->lock, flags); 133 + raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); 134 134 } 135 135 136 136 static void idio_16_irq_ack(struct irq_data *data) ··· 147 147 idio16gpio->irq_mask &= ~mask; 148 148 149 149 if (!idio16gpio->irq_mask) { 150 - spin_lock_irqsave(&idio16gpio->lock, flags); 150 + raw_spin_lock_irqsave(&idio16gpio->lock, flags); 151 151 152 152 outb(0, idio16gpio->base + 2); 153 153 154 - spin_unlock_irqrestore(&idio16gpio->lock, flags); 154 + raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); 155 155 } 156 156 } 157 157 ··· 166 166 idio16gpio->irq_mask |= mask; 167 167 168 168 if (!prev_irq_mask) { 169 - spin_lock_irqsave(&idio16gpio->lock, flags); 169 + raw_spin_lock_irqsave(&idio16gpio->lock, flags); 170 170 171 171 inb(idio16gpio->base + 2); 172 172 173 - spin_unlock_irqrestore(&idio16gpio->lock, flags); 173 + raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); 174 174 } 175 175 } 176 176 ··· 201 201 for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) 202 202 generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); 203 203 204 - spin_lock(&idio16gpio->lock); 204 + raw_spin_lock(&idio16gpio->lock); 205 205 206 206 outb(0, idio16gpio->base + 1); 207 207 208 - spin_unlock(&idio16gpio->lock); 208 + raw_spin_unlock(&idio16gpio->lock); 209 209 210 210 return IRQ_HANDLED; 211 211 } ··· 249 249 idio16gpio->base = base[id]; 250 250 idio16gpio->out_state = 0xFFFF; 251 251 252 - spin_lock_init(&idio16gpio->lock); 252 + raw_spin_lock_init(&idio16gpio->lock); 253 253 254 254 err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio); 255 255 if (err) {