Re: [PATCH 4/5] genirq: Use the common function irq_expand_nr_irqs()
From: Thomas Gleixner
Date: Tue Jan 31 2023 - 04:35:29 EST
On Sun, Jan 29 2023 at 18:57, Shanker Donthineni wrote:
> Subject: genirq: Use the common function ...
genirq: Unify irq_expand_nr_irqs()
irq_expand_nr_irqs() is implemented as a stub function for !SPARSEIRQ
builds. That's not necessary as the SPARSEIRQ version returns -ENOMEM
correctly even for the !SPARSEIRQ case as the ....
But this common function is non-obvious for the !SPARSEIRQ case. It at
least needs a comment
> +static int irq_expand_nr_irqs(unsigned int nr)
> +{
> + if (nr > MAX_SPARSE_IRQS)
> + return -ENOMEM;
> + nr_irqs = nr;
> + return 0;
> +}
or preferrably something like this:
if (!IS_ENABLED(CONFIG_SPARSEIRQ) || nr > MAX_SPARSE_IRQS)
return -ENOMEM;
which makes it entirely clear and also allows the compiler to optimize
is down to a 'return -ENOMEM'.
Thanks,
tglx