mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] of: guard pointers to key OF nodes with an #ifdef
@ 2026-01-15  9:18 Bartosz Golaszewski
  2026-01-15 14:56 ` kernel test robot
  2026-01-15 20:21 ` Rob Herring (Arm)
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-01-15  9:18 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan
  Cc: devicetree, linux-kernel, Bartosz Golaszewski

We declare the pointers to some key OF-nodes unconditionally in
linux/of.h but only export them with CONFIG_OF=y. If anyone uses them in
code built without devicetree support enabled, the problem will only come
to light at link-time. Add an #ifdef guard to catch it at compile-time.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 include/linux/of.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index 9bbdcf25a2b4..bc57dff819f8 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -138,10 +138,12 @@ static inline void of_node_put(struct device_node *node) { }
 DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T))
 
 /* Pointer for first entry in chain of all nodes. */
+#if IS_ENABLED(CONFIG_OF)
 extern struct device_node *of_root;
 extern struct device_node *of_chosen;
 extern struct device_node *of_aliases;
 extern struct device_node *of_stdout;
+#endif
 
 /*
  * struct device_node flag descriptions
-- 
2.47.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-16  3:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-15  9:18 [PATCH] of: guard pointers to key OF nodes with an #ifdef Bartosz Golaszewski
2026-01-15 14:56 ` kernel test robot
2026-01-15 20:21 ` Rob Herring (Arm)
2026-01-16  3:21   ` Rob Herring

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®