Skip to content

Commit 7e04e5c

Browse files
committed
genirq/manage: Rework __irq_apply_affinity_hint()
Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent b056158 commit 7e04e5c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

kernel/irq/manage.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,26 +480,24 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
480480
}
481481
EXPORT_SYMBOL_GPL(irq_force_affinity);
482482

483-
int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
484-
bool setaffinity)
483+
int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, bool setaffinity)
485484
{
486-
unsigned long flags;
487-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
485+
int ret = -EINVAL;
488486

489-
if (!desc)
490-
return -EINVAL;
491-
desc->affinity_hint = m;
492-
irq_put_desc_unlock(desc, flags);
493-
if (m && setaffinity)
487+
scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
488+
scoped_irqdesc->affinity_hint = m;
489+
ret = 0;
490+
}
491+
492+
if (!ret && m && setaffinity)
494493
__irq_set_affinity(irq, m, false);
495-
return 0;
494+
return ret;
496495
}
497496
EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint);
498497

499498
static void irq_affinity_notify(struct work_struct *work)
500499
{
501-
struct irq_affinity_notify *notify =
502-
container_of(work, struct irq_affinity_notify, work);
500+
struct irq_affinity_notify *notify = container_of(work, struct irq_affinity_notify, work);
503501
struct irq_desc *desc = irq_to_desc(notify->irq);
504502
cpumask_var_t cpumask;
505503

0 commit comments

Comments
 (0)