Re: [PATCH 01/21] genirq: Introduce number_of_interrupts() and set_number_of_interrupts()

From: Thomas Gleixner
Date: Tue Oct 01 2024 - 08:33:33 EST


On Mon, Sep 30 2024 at 11:15, Bart Van Assche wrote:
> This patch prepares for changing 'nr_irqs' from an exported global
> variable

git grep 'This patch' Documentation/process/

> into a variable with file scope.

Also what's the rationale for this?

>
> extern int nr_irqs;
> +int number_of_interrupts(void) __pure;
> +int set_number_of_interrupts(int nr);

Please use a proper name space prefix for the functions
irq_.....(). These random names are horrible.

> extern struct irq_desc *irq_to_desc(unsigned int irq);
> unsigned int irq_get_next_irq(unsigned int offset);
>
> diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
> index 1dee88ba0ae4..8c6280843964 100644
> --- a/kernel/irq/irqdesc.c
> +++ b/kernel/irq/irqdesc.c
> @@ -141,6 +141,20 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
> int nr_irqs = NR_IRQS;
> EXPORT_SYMBOL_GPL(nr_irqs);
>
> +int number_of_interrupts(void)
> +{
> + return nr_irqs;

Why is this int? The number of interrupts is strictly positive, no?