From: Thomas Gleixner Date: Tue, 29 Apr 2025 06:55:34 +0000 (+0200) Subject: genirq/manage: Rework __irq_apply_affinity_hint() X-Git-Tag: v6.16-rc1~189^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e04e5c6f6158d5528f0591cc6b3fc1a2b771a90;p=thirdparty%2Fkernel%2Flinux.git 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 Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/all/20250429065421.897188799@linutronix.de --- diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 81f786da2cdea..4d08a09929a4b 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -480,26 +480,24 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) } EXPORT_SYMBOL_GPL(irq_force_affinity); -int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, - bool setaffinity) +int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, bool setaffinity) { - unsigned long flags; - struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); + int ret = -EINVAL; - if (!desc) - return -EINVAL; - desc->affinity_hint = m; - irq_put_desc_unlock(desc, flags); - if (m && setaffinity) + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + scoped_irqdesc->affinity_hint = m; + ret = 0; + } + + if (!ret && m && setaffinity) __irq_set_affinity(irq, m, false); - return 0; + return ret; } EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint); static void irq_affinity_notify(struct work_struct *work) { - struct irq_affinity_notify *notify = - container_of(work, struct irq_affinity_notify, work); + struct irq_affinity_notify *notify = container_of(work, struct irq_affinity_notify, work); struct irq_desc *desc = irq_to_desc(notify->irq); cpumask_var_t cpumask;