* [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled
@ 2025-06-17 2:41 Haofeng Li
2025-09-10 15:26 ` Thomas Gleixner
0 siblings, 1 reply; 3+ messages 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] 3+ messages in thread
* Re: [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled
2025-06-17 2:41 [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled Haofeng Li
@ 2025-09-10 15:26 ` Thomas Gleixner
2025-09-12 10:17 ` Haofeng Li
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2025-09-10 15:26 UTC (permalink / raw)
To: Haofeng Li, Tony Lindgren, Kevin Hilman
Cc: Roger Quadros, Andreas Kemnade, Aaro Koskinen, linux-omap,
linux-kernel, Haofeng Li
On Tue, Jun 17 2025 at 10:41, Haofeng Li wrote:
> -
> - irq_domain_create_legacy(of_fwnode_handle(node), nr_irqs, irq_base, 0,
> +#ifdef CONFIG_OF
> + fwnode = of_fwnode_handle(dev->of_node);
> +#endif
This #ifdeffery is horrible.
> + irq_domain_create_legacy(fwnode, nr_irqs, irq_base, 0,
irq_domain_create_legacy(dev_fwnode(dev), ....
Makes all of those problems go away.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled
2025-09-10 15:26 ` Thomas Gleixner
@ 2025-09-12 10:17 ` Haofeng Li
0 siblings, 0 replies; 3+ messages in thread
From: Haofeng Li @ 2025-09-12 10:17 UTC (permalink / raw)
To: tglx
Cc: 920484857, aaro.koskinen, andreas, khilman, lihaofeng,
linux-kernel, linux-omap, rogerq, tony
>This #ifdeffery is horrible.
> + irq_domain_create_legacy(fwnode, nr_irqs, irq_base, 0,
> irq_domain_create_legacy(dev_fwnode(dev), ....
>Makes all of those problems go away.
Thank you very much for your valuable feedback. Your suggestion to use dev_fwnode(dev) to simplify the code and avoid unnecessary #ifdef conditionals is highly appreciated. This approach indeed makes the code cleaner and more maintainable.
I have noticed that this issue has already been addressed in the latest commit, and the changes have been implemented . Therefore, I am closing this submission.
Once again, thank you for your guidance and support. If you have any further suggestions or require additional input, please feel free to let me know. I look forward to continuing to learn from your insights in future developments.
Best regards,
lihaofeng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-12 10:23 UTC | newest]
Thread overview: 3+ messages (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
2025-09-10 15:26 ` Thomas Gleixner
2025-09-12 10:17 ` Haofeng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox