[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <163475563206.25758.2271119876482116679.tip-bot2@tip-bot2>
Date: Wed, 20 Oct 2021 18:47:12 -0000
From: "irqchip-bot for Marc Zyngier" <tip-bot2@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: Marc Zyngier <maz@...nel.org>, tglx@...utronix.de
Subject: [irqchip: irq/irqchip-next] irqchip: Provide stronger type checking
for IRQCHIP_MATCH/IRQCHIP_DECLARE
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: f1985002839af80d6c84e9537834a81fb1364d6e
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/f1985002839af80d6c84e9537834a81fb1364d6e
Author: Marc Zyngier <maz@...nel.org>
AuthorDate: Wed, 20 Oct 2021 09:33:21 +01:00
Committer: Marc Zyngier <maz@...nel.org>
CommitterDate: Wed, 20 Oct 2021 19:33:53 +01:00
irqchip: Provide stronger type checking for IRQCHIP_MATCH/IRQCHIP_DECLARE
Both IRQCHIP_DECLARE() and IRQCHIP_MATCH() use an underlying of_device_id()
structure to encode the matching property and the init callback.
However, this callback is stored in as a void * pointer, which obviously
defeat any attempt at stronger type checking.
Work around this by providing a new macro that builds on top of the
__typecheck() primitive, and that can be used to warn when there is
a discrepency between the drivers and core code.
Signed-off-by: Marc Zyngier <maz@...nel.org>
Link: https://lore.kernel.org/r/20211020104527.3066268-1-maz@kernel.org
---
include/linux/irqchip.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
index 67351aa..5de0dfc 100644
--- a/include/linux/irqchip.h
+++ b/include/linux/irqchip.h
@@ -14,8 +14,15 @@
#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_irq.h>
#include <linux/platform_device.h>
+/* Undefined on purpose */
+extern of_irq_init_cb_t typecheck_irq_init_cb;
+
+#define typecheck_irq_init_cb(fn) \
+ (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn)
+
/*
* This macro must be used by the different irqchip drivers to declare
* the association between their DT compatible string and their
@@ -26,14 +33,16 @@
* @compstr: compatible string of the irqchip driver
* @fn: initialization function
*/
-#define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn)
+#define IRQCHIP_DECLARE(name, compat, fn) \
+ OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn))
extern int platform_irqchip_probe(struct platform_device *pdev);
#define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
static const struct of_device_id drv_name##_irqchip_match_table[] = {
-#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
+#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \
+ .data = typecheck_irq_init_cb(fn), },
#define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \
{}, \
Powered by blists - more mailing lists