Skip to content

Commit 195298c

Browse files
committed
genirq/generic-chip: Convert core code to lock guards
Replace the irq_gc_lock/unlock() pairs with guards. There is no point to implement a guard wrapper for them as they just wrap around raw_spin_lock*(). Switch the other lock instances in the core code to guards as well. Conversion was done with Coccinelle plus manual fixups. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 06f2f68 commit 195298c

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

kernel/irq/generic-chip.c

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ void irq_gc_mask_disable_reg(struct irq_data *d)
4040
struct irq_chip_type *ct = irq_data_get_chip_type(d);
4141
u32 mask = d->mask;
4242

43-
irq_gc_lock(gc);
43+
guard(raw_spinlock)(&gc->lock);
4444
irq_reg_writel(gc, mask, ct->regs.disable);
4545
*ct->mask_cache &= ~mask;
46-
irq_gc_unlock(gc);
4746
}
4847
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_reg);
4948

@@ -60,10 +59,9 @@ void irq_gc_mask_set_bit(struct irq_data *d)
6059
struct irq_chip_type *ct = irq_data_get_chip_type(d);
6160
u32 mask = d->mask;
6261

63-
irq_gc_lock(gc);
62+
guard(raw_spinlock)(&gc->lock);
6463
*ct->mask_cache |= mask;
6564
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
66-
irq_gc_unlock(gc);
6765
}
6866
EXPORT_SYMBOL_GPL(irq_gc_mask_set_bit);
6967

@@ -80,10 +78,9 @@ void irq_gc_mask_clr_bit(struct irq_data *d)
8078
struct irq_chip_type *ct = irq_data_get_chip_type(d);
8179
u32 mask = d->mask;
8280

83-
irq_gc_lock(gc);
81+
guard(raw_spinlock)(&gc->lock);
8482
*ct->mask_cache &= ~mask;
8583
irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
86-
irq_gc_unlock(gc);
8784
}
8885
EXPORT_SYMBOL_GPL(irq_gc_mask_clr_bit);
8986

@@ -100,10 +97,9 @@ void irq_gc_unmask_enable_reg(struct irq_data *d)
10097
struct irq_chip_type *ct = irq_data_get_chip_type(d);
10198
u32 mask = d->mask;
10299

103-
irq_gc_lock(gc);
100+
guard(raw_spinlock)(&gc->lock);
104101
irq_reg_writel(gc, mask, ct->regs.enable);
105102
*ct->mask_cache |= mask;
106-
irq_gc_unlock(gc);
107103
}
108104
EXPORT_SYMBOL_GPL(irq_gc_unmask_enable_reg);
109105

@@ -117,9 +113,8 @@ void irq_gc_ack_set_bit(struct irq_data *d)
117113
struct irq_chip_type *ct = irq_data_get_chip_type(d);
118114
u32 mask = d->mask;
119115

120-
irq_gc_lock(gc);
116+
guard(raw_spinlock)(&gc->lock);
121117
irq_reg_writel(gc, mask, ct->regs.ack);
122-
irq_gc_unlock(gc);
123118
}
124119
EXPORT_SYMBOL_GPL(irq_gc_ack_set_bit);
125120

@@ -133,9 +128,8 @@ void irq_gc_ack_clr_bit(struct irq_data *d)
133128
struct irq_chip_type *ct = irq_data_get_chip_type(d);
134129
u32 mask = ~d->mask;
135130

136-
irq_gc_lock(gc);
131+
guard(raw_spinlock)(&gc->lock);
137132
irq_reg_writel(gc, mask, ct->regs.ack);
138-
irq_gc_unlock(gc);
139133
}
140134

141135
/**
@@ -156,11 +150,10 @@ void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
156150
struct irq_chip_type *ct = irq_data_get_chip_type(d);
157151
u32 mask = d->mask;
158152

159-
irq_gc_lock(gc);
153+
guard(raw_spinlock)(&gc->lock);
160154
irq_reg_writel(gc, mask, ct->regs.disable);
161155
*ct->mask_cache &= ~mask;
162156
irq_reg_writel(gc, mask, ct->regs.ack);
163-
irq_gc_unlock(gc);
164157
}
165158
EXPORT_SYMBOL_GPL(irq_gc_mask_disable_and_ack_set);
166159

@@ -174,9 +167,8 @@ void irq_gc_eoi(struct irq_data *d)
174167
struct irq_chip_type *ct = irq_data_get_chip_type(d);
175168
u32 mask = d->mask;
176169

177-
irq_gc_lock(gc);
170+
guard(raw_spinlock)(&gc->lock);
178171
irq_reg_writel(gc, mask, ct->regs.eoi);
179-
irq_gc_unlock(gc);
180172
}
181173

182174
/**
@@ -196,12 +188,11 @@ int irq_gc_set_wake(struct irq_data *d, unsigned int on)
196188
if (!(mask & gc->wake_enabled))
197189
return -EINVAL;
198190

199-
irq_gc_lock(gc);
191+
guard(raw_spinlock)(&gc->lock);
200192
if (on)
201193
gc->wake_active |= mask;
202194
else
203195
gc->wake_active &= ~mask;
204-
irq_gc_unlock(gc);
205196
return 0;
206197
}
207198
EXPORT_SYMBOL_GPL(irq_gc_set_wake);
@@ -288,7 +279,6 @@ int irq_domain_alloc_generic_chips(struct irq_domain *d,
288279
{
289280
struct irq_domain_chip_generic *dgc;
290281
struct irq_chip_generic *gc;
291-
unsigned long flags;
292282
int numchips, i;
293283
size_t dgc_sz;
294284
size_t gc_sz;
@@ -340,9 +330,8 @@ int irq_domain_alloc_generic_chips(struct irq_domain *d,
340330
goto err;
341331
}
342332

343-
raw_spin_lock_irqsave(&gc_lock, flags);
344-
list_add_tail(&gc->list, &gc_list);
345-
raw_spin_unlock_irqrestore(&gc_lock, flags);
333+
scoped_guard (raw_spinlock, &gc_lock)
334+
list_add_tail(&gc->list, &gc_list);
346335
/* Calc pointer to the next generic chip */
347336
tmp += gc_sz;
348337
}
@@ -459,7 +448,6 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
459448
struct irq_chip_generic *gc;
460449
struct irq_chip_type *ct;
461450
struct irq_chip *chip;
462-
unsigned long flags;
463451
int idx;
464452

465453
gc = __irq_get_domain_generic_chip(d, hw_irq);
@@ -479,9 +467,8 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
479467

480468
/* We only init the cache for the first mapping of a generic chip */
481469
if (!gc->installed) {
482-
raw_spin_lock_irqsave(&gc->lock, flags);
470+
guard(raw_spinlock_irq)(&gc->lock);
483471
irq_gc_init_mask_cache(gc, dgc->gc_flags);
484-
raw_spin_unlock_irqrestore(&gc->lock, flags);
485472
}
486473

487474
/* Mark the interrupt as installed */
@@ -548,9 +535,8 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
548535
struct irq_chip *chip = &ct->chip;
549536
unsigned int i;
550537

551-
raw_spin_lock(&gc_lock);
552-
list_add_tail(&gc->list, &gc_list);
553-
raw_spin_unlock(&gc_lock);
538+
scoped_guard (raw_spinlock, &gc_lock)
539+
list_add_tail(&gc->list, &gc_list);
554540

555541
irq_gc_init_mask_cache(gc, flags);
556542

@@ -616,9 +602,8 @@ void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
616602
{
617603
unsigned int i, virq;
618604

619-
raw_spin_lock(&gc_lock);
620-
list_del(&gc->list);
621-
raw_spin_unlock(&gc_lock);
605+
scoped_guard (raw_spinlock, &gc_lock)
606+
list_del(&gc->list);
622607

623608
for (i = 0; msk; msk >>= 1, i++) {
624609
if (!(msk & 0x01))

0 commit comments

Comments
 (0)