diff mbox series

[v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled

Message ID tencent_C3FBDADE7060045B2952DE00576F922C5E06@qq.com
State New
Headers show
Series [v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled | expand

Commit Message

Haofeng Li June 17, 2025, 2:41 a.m. UTC
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 mbox series

Patch

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;