[PATCH -next] genirq: Simplify the checks for irq_set_percpu_devid_partition()

From: Jinjie Ruan
Date: Wed Apr 17 2024 - 04:53:56 EST


Since whether desc is NULL or desc->percpu_enabled is true, it returns
-EINVAL, check them together, and assign desc->percpu_affinity
using "?:" to simplify the code.

Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
kernel/irq/irqdesc.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 23120e5a46a9..6b19c72db29a 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -911,10 +911,7 @@ int irq_set_percpu_devid_partition(unsigned int irq,
{
struct irq_desc *desc = irq_to_desc(irq);

- if (!desc)
- return -EINVAL;
-
- if (desc->percpu_enabled)
+ if (!desc || desc->percpu_enabled)
return -EINVAL;

desc->percpu_enabled = kzalloc(sizeof(*desc->percpu_enabled), GFP_KERNEL);
@@ -922,10 +919,7 @@ int irq_set_percpu_devid_partition(unsigned int irq,
if (!desc->percpu_enabled)
return -ENOMEM;

- if (affinity)
- desc->percpu_affinity = affinity;
- else
- desc->percpu_affinity = cpu_possible_mask;
+ desc->percpu_affinity = affinity ? affinity : cpu_possible_mask;

irq_set_percpu_devid_flags(irq);
return 0;
--
2.34.1