]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
genirq/manage: Rework __irq_apply_affinity_hint()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 29 Apr 2025 06:55:34 +0000 (08:55 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 7 May 2025 07:08:15 +0000 (09:08 +0200)
Use the new guards to get and lock the interrupt descriptor 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/20250429065421.897188799@linutronix.de
kernel/irq/manage.c

index 81f786da2cdea610d1dfeffd060fe727c119e470..4d08a09929a4b07b68be093fb9b6ee0a3037c421 100644 (file)
@@ -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;