From: Haofeng Li <920484857@qq.com>
To: Tony Lindgren <tony@atomide.com>, Kevin Hilman <khilman@baylibre.com>
Cc: Roger Quadros <rogerq@kernel.org>,
Andreas Kemnade <andreas@kemnade.info>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
Haofeng Li <lihaofeng@kylinos.cn>
Subject: [PATCH v1] mfd: twl4030-irq: Fix unused variable warning when CONFIG_OF disabled
Date: Tue, 17 Jun 2025 10:41:30 +0800 [thread overview]
Message-ID: <tencent_C3FBDADE7060045B2952DE00576F922C5E06@qq.com> (raw)
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
next reply other threads:[~2025-06-17 2:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 2:41 Haofeng Li [this message]
2025-09-10 15:26 ` Thomas Gleixner
2025-09-12 10:17 ` Haofeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_C3FBDADE7060045B2952DE00576F922C5E06@qq.com \
--to=920484857@qq.com \
--cc=aaro.koskinen@iki.fi \
--cc=andreas@kemnade.info \
--cc=khilman@baylibre.com \
--cc=lihaofeng@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=rogerq@kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®