From: Bart Van Assche <bvanassche@acm.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
Date: Tue, 15 Oct 2024 12:09:32 -0700 [thread overview]
Message-ID: <20241015190953.1266194-2-bvanassche@acm.org> (raw)
In-Reply-To: <20241015190953.1266194-1-bvanassche@acm.org>
Prepare for changing 'nr_irqs' from an exported global variable into a
variable with file scope. This will prevent accidental changes of
assignments to a local variable 'nr_irqs' into assignments to the global
'nr_irqs' variable. Suppose that a patch would be submitted for review that
removes a declaration of a local variable with the name 'nr_irqs' and that
that patch does not remove all assignments to that local variable. Such a
patch converts an assignment to a local variable into an assignment into a
global variable. If the 'nr_irqs' assignment is more than three lines away
from other changes, the assignment won't be included in the diff context
lines and hence won't be visible without inspecting the modified file. With
this patch series applied, such accidental conversions from assignments to
a local variable into an assignment to a global variable are converted into
a compilation error.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/linux/irqnr.h | 2 ++
kernel/irq/irqdesc.c | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 3496baa0b07f..7419b807b71b 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -6,6 +6,8 @@
extern int nr_irqs;
+unsigned int irq_get_nr_irqs(void) __pure;
+unsigned int irq_set_nr_irqs(unsigned int nr);
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..b0733959f8ae 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -141,6 +141,29 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);
+/**
+ * irq_get_nr_irqs() - Number of interrupts supported by the system.
+ */
+unsigned int irq_get_nr_irqs(void)
+{
+ return nr_irqs;
+}
+EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
+
+/**
+ * irq_set_nr_irqs() - Set the number of interrupts supported by the system.
+ * @nr: New number of interrupts.
+ *
+ * Return: @nr.
+ */
+unsigned int irq_set_nr_irqs(unsigned int nr)
+{
+ nr_irqs = nr;
+
+ return nr;
+}
+EXPORT_SYMBOL_GPL(irq_set_nr_irqs);
+
static DEFINE_MUTEX(sparse_irq_lock);
static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
MT_FLAGS_ALLOC_RANGE |
next prev parent reply other threads:[~2024-10-15 19:10 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
2024-10-15 19:09 ` Bart Van Assche [this message]
2024-10-16 20:04 ` [tip: irq/core] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-15 23:36 ` Michael Ellerman
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 05/22] s390/irq: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 08/22] net: 3com: 3c59x: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 10/22] net: hamradio: scc: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 11/22] scsi: aha152x: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 12/22] serial: core: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 13/22] serial: 8250: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 14/22] serial: amba-pl010: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 15/22] serial: amba-pl011: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 16/22] serial: cpm_uart: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 17/22] serial: ucc_uart: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 18/22] sh: intc: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 19/22] xen/events: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 20/22] fs/procfs: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 21/22] genirq: " Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 22/22] genirq: Unexport nr_irqs Bart Van Assche
2024-10-16 20:04 ` [tip: irq/core] " tip-bot2 for Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241015190953.1266194-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox