Skip to contentSkip to conversation

of: add more dummy helper functions

PATCH In review Arnd Bergmann 2 participants 2 messages Jan 8, 2020 – Jan 14, 2020 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 of: add more dummy helper functions

The new phy-j721e-wiz driver causes a link failure without CONFIG_OF:

drivers/phy/ti/phy-j721e-wiz.o: In function `wiz_remove':
phy-j721e-wiz.c:(.text+0x40): undefined reference to `of_platform_device_destroy'

Add a dummy version of of_platform_device_destroy to avoid having to add Kconfig dependencies for the driver. As there are a few other functions without dummy implementations, add those as well for completeness.

Fixes 42440de5438a ("phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC")
---
 include/linux/of_platform.h | 39 ++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)
include/linux/of_platform.h +30 -9
index 84a966623e78..f5dea3de4856 100644
@@ -48,28 +48,49 @@ struct of_dev_auxdata {
 
 extern const struct of_device_id of_default_bus_match_table[];
 
+#ifdef CONFIG_OF
 /* Platform drivers register/unregister */
 extern struct platform_device *of_device_alloc(struct device_node *np,
 					 const char *bus_id,
 					 struct device *parent);
-#ifdef CONFIG_OF
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
-#else
-static inline struct platform_device *of_find_device_by_node(struct device_node *np)
-{
-	return NULL;
-}
-#endif
-
 /* Platform devices and busses creation */
 extern struct platform_device *of_platform_device_create(struct device_node *np,
 						   const char *bus_id,
 						   struct device *parent);
-
 extern int of_platform_device_destroy(struct device *dev, void *data);
 extern int of_platform_bus_probe(struct device_node *root,
 				 const struct of_device_id *matches,
 				 struct device *parent);
+#else
+static inline struct platform_device *of_device_alloc(struct device_node *np,
+						      const char *bus_id,
+						      struct device *parent)
+{
+	return NULL;
+}
+static inline struct platform_device *of_find_device_by_node(struct device_node *np)
+{
+	return NULL;
+}
+static inline struct platform_device *of_platform_device_create(struct device_node *np,
+								const char *bus_id,
+								struct device *parent)
+{
+	return NULL;
+}
+static inline int of_platform_device_destroy(struct device *dev, void *data)
+{
+	return 0;
+}
+static inline int of_platform_bus_probe(struct device_node *root,
+					const struct of_device_id *matches,
+					struct device *parent)
+{
+	return -ENODEV;
+}
+#endif
+
 #ifdef CONFIG_OF_ADDRESS
 extern int of_platform_populate(struct device_node *root,
 				const struct of_device_id *matches,
Signature · 1 line
2.20.0
maintainer
#1 lore raw
Quoted 63 lines · Arnd Bergmann

The new phy-j721e-wiz driver causes a link failure without CONFIG_OF:

drivers/phy/ti/phy-j721e-wiz.o: In function `wiz_remove':
phy-j721e-wiz.c:(.text+0x40): undefined reference to `of_platform_device_destroy'

Add a dummy version of of_platform_device_destroy to avoid having to add Kconfig dependencies for the driver. As there are a few other functions without dummy implementations, add those as well for completeness.

Fixes 42440de5438a ("phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC")
---
 include/linux/of_platform.h | 39 ++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)
include/linux/of_platform.h +18 -9
index 84a966623e78..f5dea3de4856 100644
@@ -48,28 +48,49 @@ struct of_dev_auxdata {
 
 extern const struct of_device_id of_default_bus_match_table[];
 
+#ifdef CONFIG_OF
 /* Platform drivers register/unregister */
 extern struct platform_device *of_device_alloc(struct device_node *np,
 					 const char *bus_id,
 					 struct device *parent);
-#ifdef CONFIG_OF
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
-#else
-static inline struct platform_device *of_find_device_by_node(struct device_node *np)
-{
-	return NULL;
-}
-#endif
-
 /* Platform devices and busses creation */
 extern struct platform_device *of_platform_device_create(struct device_node *np,
 						   const char *bus_id,
 						   struct device *parent);
-
 extern int of_platform_device_destroy(struct device *dev, void *data);
 extern int of_platform_bus_probe(struct device_node *root,
 				 const struct of_device_id *matches,
 				 struct device *parent);
+#else
+static inline struct platform_device *of_device_alloc(struct device_node *np,
+						      const char *bus_id,
+						      struct device *parent)
+{
+	return NULL;
+}
+static inline struct platform_device *of_find_device_by_node(struct device_node *np)
+{
+	return NULL;
+}
+static inline struct platform_device *of_platform_device_create(struct device_node *np,
+								const char *bus_id,
+								struct device *parent)
+{
+	return NULL;
+}

include/linux/of_platform.h struct of_dev_auxdata { · line 91

Quoted 10 lines
include/linux/of_platform.h +10 -0
+static inline int of_platform_device_destroy(struct device *dev, void *data)
+{
+	return 0;
+}
+static inline int of_platform_bus_probe(struct device_node *root,
+					const struct of_device_id *matches,
+					struct device *parent)
+{
+	return -ENODEV;
+}

This and of_device_alloc are pretty much only powerpc functions, so I want things to break if there are new users. There's one user of of_device_alloc() and a couple for of_platform_bus_probe() which is deprecated in favor of of_platform_populate(). I think we can get rid of the remaining x86 callers.

(I have the same opinion on of_platform_device_create too, but I've given up on that).

Rob