Skip to content

Commit 19b4b14

Browse files
committed
genirq/pm: Switch to lock guards
Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/all/20250429065420.251299112@linutronix.de
1 parent e80618b commit 19b4b14

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

kernel/irq/pm.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ void irq_pm_install_action(struct irq_desc *desc, struct irqaction *action)
4646
desc->cond_suspend_depth++;
4747

4848
WARN_ON_ONCE(desc->no_suspend_depth &&
49-
(desc->no_suspend_depth +
50-
desc->cond_suspend_depth) != desc->nr_actions);
49+
(desc->no_suspend_depth + desc->cond_suspend_depth) != desc->nr_actions);
5150
}
5251

5352
/*
@@ -134,14 +133,12 @@ void suspend_device_irqs(void)
134133
int irq;
135134

136135
for_each_irq_desc(irq, desc) {
137-
unsigned long flags;
138136
bool sync;
139137

140138
if (irq_settings_is_nested_thread(desc))
141139
continue;
142-
raw_spin_lock_irqsave(&desc->lock, flags);
143-
sync = suspend_device_irq(desc);
144-
raw_spin_unlock_irqrestore(&desc->lock, flags);
140+
scoped_guard(raw_spinlock_irqsave, &desc->lock)
141+
sync = suspend_device_irq(desc);
145142

146143
if (sync)
147144
synchronize_irq(irq);
@@ -186,18 +183,15 @@ static void resume_irqs(bool want_early)
186183
int irq;
187184

188185
for_each_irq_desc(irq, desc) {
189-
unsigned long flags;
190-
bool is_early = desc->action &&
191-
desc->action->flags & IRQF_EARLY_RESUME;
186+
bool is_early = desc->action && desc->action->flags & IRQF_EARLY_RESUME;
192187

193188
if (!is_early && want_early)
194189
continue;
195190
if (irq_settings_is_nested_thread(desc))
196191
continue;
197192

198-
raw_spin_lock_irqsave(&desc->lock, flags);
193+
guard(raw_spinlock_irqsave)(&desc->lock);
199194
resume_irq(desc);
200-
raw_spin_unlock_irqrestore(&desc->lock, flags);
201195
}
202196
}
203197

@@ -207,22 +201,16 @@ static void resume_irqs(bool want_early)
207201
*/
208202
void rearm_wake_irq(unsigned int irq)
209203
{
210-
unsigned long flags;
211-
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
204+
scoped_irqdesc_get_and_buslock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
205+
struct irq_desc *desc = scoped_irqdesc;
212206

213-
if (!desc)
214-
return;
215-
216-
if (!(desc->istate & IRQS_SUSPENDED) ||
217-
!irqd_is_wakeup_set(&desc->irq_data))
218-
goto unlock;
219-
220-
desc->istate &= ~IRQS_SUSPENDED;
221-
irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
222-
__enable_irq(desc);
207+
if (!(desc->istate & IRQS_SUSPENDED) || !irqd_is_wakeup_set(&desc->irq_data))
208+
return;
223209

224-
unlock:
225-
irq_put_desc_busunlock(desc, flags);
210+
desc->istate &= ~IRQS_SUSPENDED;
211+
irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
212+
__enable_irq(desc);
213+
}
226214
}
227215

228216
/**

0 commit comments

Comments
 (0)