Re: [PATCH] irqchip: Provide stronger type checking for IRQCHIP_MATCH/IRQCHIP_DECLARE

From: Marc Zyngier
Date: Thu Oct 28 2021 - 14:43:24 EST


On 2021-10-28 18:28, Guenter Roeck wrote:
On Wed, Oct 20, 2021 at 11:45:27AM +0100, Marc Zyngier wrote:
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@xxxxxxxxxx>

This patch results in:

In file included from include/linux/irq.h:589,
from include/linux/of_irq.h:7,
from include/linux/irqchip.h:17,
from arch/h8300/include/asm/irq.h:5,
from arch/h8300/kernel/traps.c:27:
include/linux/irqdesc.h:113:33: error: 'NR_IRQS' undeclared here (not
in a function)
113 | extern struct irq_desc irq_desc[NR_IRQS];

and many similar errors when trying to build h8300 images.

Sigh... Please give this [1] a go.

M.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/misc-5.16&id=0646880e517c06f0e0746665ca1e0e6dd36c406e

--
Jazz is not dead. It just smells funny...