Skip to content

Commit b056158

Browse files
committed
genirq/manage: Rework irq_update_affinity_desc()
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 17c1953 commit b056158

File tree

1 file changed

+28
-40
lines changed

1 file changed

+28
-40
lines changed

kernel/irq/manage.c

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -395,59 +395,47 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
395395
* an interrupt which is already started or which has already been configured
396396
* as managed will also fail, as these mean invalid init state or double init.
397397
*/
398-
int irq_update_affinity_desc(unsigned int irq,
399-
struct irq_affinity_desc *affinity)
398+
int irq_update_affinity_desc(unsigned int irq, struct irq_affinity_desc *affinity)
400399
{
401-
struct irq_desc *desc;
402-
unsigned long flags;
403-
bool activated;
404-
int ret = 0;
405-
406400
/*
407401
* Supporting this with the reservation scheme used by x86 needs
408402
* some more thought. Fail it for now.
409403
*/
410404
if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE))
411405
return -EOPNOTSUPP;
412406

413-
desc = irq_get_desc_buslock(irq, &flags, 0);
414-
if (!desc)
415-
return -EINVAL;
407+
scoped_irqdesc_get_and_buslock(irq, 0) {
408+
struct irq_desc *desc = scoped_irqdesc;
409+
bool activated;
416410

417-
/* Requires the interrupt to be shut down */
418-
if (irqd_is_started(&desc->irq_data)) {
419-
ret = -EBUSY;
420-
goto out_unlock;
421-
}
422-
423-
/* Interrupts which are already managed cannot be modified */
424-
if (irqd_affinity_is_managed(&desc->irq_data)) {
425-
ret = -EBUSY;
426-
goto out_unlock;
427-
}
411+
/* Requires the interrupt to be shut down */
412+
if (irqd_is_started(&desc->irq_data))
413+
return -EBUSY;
428414

429-
/*
430-
* Deactivate the interrupt. That's required to undo
431-
* anything an earlier activation has established.
432-
*/
433-
activated = irqd_is_activated(&desc->irq_data);
434-
if (activated)
435-
irq_domain_deactivate_irq(&desc->irq_data);
436-
437-
if (affinity->is_managed) {
438-
irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED);
439-
irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN);
440-
}
415+
/* Interrupts which are already managed cannot be modified */
416+
if (irqd_affinity_is_managed(&desc->irq_data))
417+
return -EBUSY;
418+
/*
419+
* Deactivate the interrupt. That's required to undo
420+
* anything an earlier activation has established.
421+
*/
422+
activated = irqd_is_activated(&desc->irq_data);
423+
if (activated)
424+
irq_domain_deactivate_irq(&desc->irq_data);
441425

442-
cpumask_copy(desc->irq_common_data.affinity, &affinity->mask);
426+
if (affinity->is_managed) {
427+
irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED);
428+
irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN);
429+
}
443430

444-
/* Restore the activation state */
445-
if (activated)
446-
irq_domain_activate_irq(&desc->irq_data, false);
431+
cpumask_copy(desc->irq_common_data.affinity, &affinity->mask);
447432

448-
out_unlock:
449-
irq_put_desc_busunlock(desc, flags);
450-
return ret;
433+
/* Restore the activation state */
434+
if (activated)
435+
irq_domain_activate_irq(&desc->irq_data, false);
436+
return 0;
437+
}
438+
return -EINVAL;
451439
}
452440

453441
static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask,

0 commit comments

Comments
 (0)