* [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled
@ 2025-06-17 2:41 Haofeng Li
0 siblings, 0 replies; only message in thread
From: Haofeng Li @ 2025-06-17 2:41 UTC (permalink / raw)
To: Tony Lindgren, Kevin Hilman
Cc: Roger Quadros, Andreas Kemnade, Aaro Koskinen, linux-omap,
linux-kernel, Haofeng Li
From: Haofeng Li <lihaofeng@kylinos.cn>
With compile testing on non-OF platforms, compiler reports:
../drivers/mfd/twl4030-irq.c:679:46: error: unused variable 'node' [-Werror=unused-variable]
679 | struct device_node *node = dev->of_node;
This occurs because:
1. of_fwnode_handle() is unavailable without CONFIG_OF
2. The 'node' variable becomes unused
3. -Werror flags the unused variable as an error
Fix by:
1. Replace device_node pointer with fwnode_handle pointer,
initialized to NULL
2. Only setting fwnode when CONFIG_OF is enabled
3. Passing fwnode to irq_domain_create_legacy()
Passing NULL fwnode is safe:
- irq_domain_create_legacy() accepts NULL fwnode_handle
- The function has appropriate NULL checks in its implementation
- Equivalent to original behavior when CONFIG_OF is disabled
Signed-off-by: Haofeng Li <lihaofeng@kylinos.cn>
---
drivers/mfd/twl4030-irq.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 232c2bfe8c18..8297966bd957 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -676,7 +676,7 @@ int twl4030_init_irq(struct device *dev, int irq_num)
static struct irq_chip twl4030_irq_chip;
int status, i;
int irq_base, irq_end, nr_irqs;
- struct device_node *node = dev->of_node;
+ struct fwnode_handle *fwnode = NULL;
/*
* TWL core and pwr interrupts must be contiguous because
@@ -690,8 +690,10 @@ int twl4030_init_irq(struct device *dev, int irq_num)
dev_err(dev, "Fail to allocate IRQ descs\n");
return irq_base;
}
-
- irq_domain_create_legacy(of_fwnode_handle(node), nr_irqs, irq_base, 0,
+#ifdef CONFIG_OF
+ fwnode = of_fwnode_handle(dev->of_node);
+#endif
+ irq_domain_create_legacy(fwnode, nr_irqs, irq_base, 0,
&irq_domain_simple_ops, NULL);
irq_end = irq_base + TWL4030_CORE_NR_IRQS;
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-17 2:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 2:41 [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled Haofeng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).