Skip to content

Commit ea38ce0

Browse files
Julia Cartwrightlinusw
authored andcommitted
gpio: pci-idio-16: make use of raw_spinlock variants
The pci-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>
1 parent 3906e80 commit ea38ce0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/gpio/gpio-pci-idio-16.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct idio_16_gpio_reg {
5959
*/
6060
struct idio_16_gpio {
6161
struct gpio_chip chip;
62-
spinlock_t lock;
62+
raw_spinlock_t lock;
6363
struct idio_16_gpio_reg __iomem *reg;
6464
unsigned long irq_mask;
6565
};
@@ -121,7 +121,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset,
121121
} else
122122
base = &idio16gpio->reg->out0_7;
123123

124-
spin_lock_irqsave(&idio16gpio->lock, flags);
124+
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
125125

126126
if (value)
127127
out_state = ioread8(base) | mask;
@@ -130,7 +130,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset,
130130

131131
iowrite8(out_state, base);
132132

133-
spin_unlock_irqrestore(&idio16gpio->lock, flags);
133+
raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
134134
}
135135

136136
static void idio_16_gpio_set_multiple(struct gpio_chip *chip,
@@ -140,7 +140,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip,
140140
unsigned long flags;
141141
unsigned int out_state;
142142

143-
spin_lock_irqsave(&idio16gpio->lock, flags);
143+
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
144144

145145
/* process output lines 0-7 */
146146
if (*mask & 0xFF) {
@@ -160,7 +160,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip,
160160
iowrite8(out_state, &idio16gpio->reg->out8_15);
161161
}
162162

163-
spin_unlock_irqrestore(&idio16gpio->lock, flags);
163+
raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
164164
}
165165

166166
static void idio_16_irq_ack(struct irq_data *data)
@@ -177,11 +177,11 @@ static void idio_16_irq_mask(struct irq_data *data)
177177
idio16gpio->irq_mask &= ~mask;
178178

179179
if (!idio16gpio->irq_mask) {
180-
spin_lock_irqsave(&idio16gpio->lock, flags);
180+
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
181181

182182
iowrite8(0, &idio16gpio->reg->irq_ctl);
183183

184-
spin_unlock_irqrestore(&idio16gpio->lock, flags);
184+
raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
185185
}
186186
}
187187

@@ -196,11 +196,11 @@ static void idio_16_irq_unmask(struct irq_data *data)
196196
idio16gpio->irq_mask |= mask;
197197

198198
if (!prev_irq_mask) {
199-
spin_lock_irqsave(&idio16gpio->lock, flags);
199+
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
200200

201201
ioread8(&idio16gpio->reg->irq_ctl);
202202

203-
spin_unlock_irqrestore(&idio16gpio->lock, flags);
203+
raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
204204
}
205205
}
206206

@@ -229,11 +229,11 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
229229
struct gpio_chip *const chip = &idio16gpio->chip;
230230
int gpio;
231231

232-
spin_lock(&idio16gpio->lock);
232+
raw_spin_lock(&idio16gpio->lock);
233233

234234
irq_status = ioread8(&idio16gpio->reg->irq_status);
235235

236-
spin_unlock(&idio16gpio->lock);
236+
raw_spin_unlock(&idio16gpio->lock);
237237

238238
/* Make sure our device generated IRQ */
239239
if (!(irq_status & 0x3) || !(irq_status & 0x4))
@@ -242,12 +242,12 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
242242
for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio)
243243
generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio));
244244

245-
spin_lock(&idio16gpio->lock);
245+
raw_spin_lock(&idio16gpio->lock);
246246

247247
/* Clear interrupt */
248248
iowrite8(0, &idio16gpio->reg->in0_7);
249249

250-
spin_unlock(&idio16gpio->lock);
250+
raw_spin_unlock(&idio16gpio->lock);
251251

252252
return IRQ_HANDLED;
253253
}
@@ -302,7 +302,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
302302
idio16gpio->chip.set = idio_16_gpio_set;
303303
idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple;
304304

305-
spin_lock_init(&idio16gpio->lock);
305+
raw_spin_lock_init(&idio16gpio->lock);
306306

307307
err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio);
308308
if (err) {

0 commit comments

Comments
 (0)