diff mbox

phy: leave out DT based interfaces without CONFIG_OF

Message ID 1461750901-2704136-1-git-send-email-arnd@arndb.de
State New
Headers show

Commit Message

Arnd Bergmann April 27, 2016, 9:54 a.m. UTC
After a recent change in the PHY core, we get a build error when
CONFIG_OF is disabled:

drivers/phy/phy-core.c: In function '__of_phy_provider_register':
drivers/phy/phy-core.c:848:13: error: implicit declaration of function 'of_get_next_parent' [-Werror=implicit-function-declaration]

It would not be hard to avoid this error by adding a declaration
for of_get_next_parent, but I'm taking a different approach here
and remove all the unused DT handling from the PHY core in
configurations with CONFIG_OF, which avoids the build error and
reduces the object code size.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Fixes: 2f7600bc981c ("phy: core: Allow children node to be overridden")
---
 drivers/phy/phy-core.c  |  20 ++++++++--
 include/linux/phy/phy.h | 101 +++++++++++++++++++++++++-----------------------
 2 files changed, 69 insertions(+), 52 deletions(-)

-- 
2.7.0
diff mbox

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 4e905a4313c0..bb03fcc65497 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -36,12 +36,14 @@  static void devm_phy_release(struct device *dev, void *res)
 	phy_put(phy);
 }
 
+#ifdef CONFIG_OF
 static void devm_phy_provider_release(struct device *dev, void *res)
 {
 	struct phy_provider *phy_provider = *(struct phy_provider **)res;
 
 	of_phy_provider_unregister(phy_provider);
 }
+#endif
 
 static void devm_phy_consume(struct device *dev, void *res)
 {
@@ -132,6 +134,7 @@  static struct phy *phy_find(struct device *dev, const char *con_id)
 	return pl ? pl->phy : ERR_PTR(-ENODEV);
 }
 
+#ifdef CONFIG_OF
 static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
 {
 	struct phy_provider *phy_provider;
@@ -148,6 +151,7 @@  static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
 
 	return ERR_PTR(-EPROBE_DEFER);
 }
+#endif
 
 int phy_pm_runtime_get(struct phy *phy)
 {
@@ -342,6 +346,7 @@  int phy_power_off(struct phy *phy)
 }
 EXPORT_SYMBOL_GPL(phy_power_off);
 
+#ifdef CONFIG_OF
 /**
  * _of_phy_get() - lookup and obtain a reference to a phy by phandle
  * @np: device_node for which to get the phy
@@ -419,6 +424,7 @@  struct phy *of_phy_get(struct device_node *np, const char *con_id)
 	return phy;
 }
 EXPORT_SYMBOL_GPL(of_phy_get);
+#endif
 
 /**
  * phy_put() - release the PHY
@@ -456,6 +462,7 @@  void devm_phy_put(struct device *dev, struct phy *phy)
 }
 EXPORT_SYMBOL_GPL(devm_phy_put);
 
+#ifdef CONFIG_OF
 /**
  * of_phy_simple_xlate() - returns the phy instance from phy provider
  * @dev: the PHY provider device
@@ -486,6 +493,7 @@  struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args
 	return ERR_PTR(-ENODEV);
 }
 EXPORT_SYMBOL_GPL(of_phy_simple_xlate);
+#endif
 
 /**
  * phy_get() - lookup and obtain a reference to a phy.
@@ -499,21 +507,21 @@  EXPORT_SYMBOL_GPL(of_phy_simple_xlate);
  */
 struct phy *phy_get(struct device *dev, const char *string)
 {
-	int index = 0;
 	struct phy *phy;
 
 	if (string == NULL) {
 		dev_WARN(dev, "missing string\n");
 		return ERR_PTR(-EINVAL);
 	}
-
+#ifdef CONFIG_OF
 	if (dev->of_node) {
+		int index;
 		index = of_property_match_string(dev->of_node, "phy-names",
 			string);
 		phy = _of_phy_get(dev->of_node, index);
-	} else {
+	} else
+#endif
 		phy = phy_find(dev, string);
-	}
 	if (IS_ERR(phy))
 		return phy;
 
@@ -601,6 +609,7 @@  struct phy *devm_phy_optional_get(struct device *dev, const char *string)
 }
 EXPORT_SYMBOL_GPL(devm_phy_optional_get);
 
+#ifdef CONFIG_OF
 /**
  * devm_of_phy_get() - lookup and obtain a reference to a phy.
  * @dev: device that requests this phy
@@ -672,6 +681,7 @@  struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
 	return phy;
 }
 EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
+#endif
 
 /**
  * phy_create() - create a new phy
@@ -808,6 +818,7 @@  void devm_phy_destroy(struct device *dev, struct phy *phy)
 }
 EXPORT_SYMBOL_GPL(devm_phy_destroy);
 
+#ifdef CONFIG_OF
 /**
  * __of_phy_provider_register() - create/register phy provider with the framework
  * @dev: struct device of the phy provider
@@ -945,6 +956,7 @@  void devm_of_phy_provider_unregister(struct device *dev,
 	dev_WARN_ONCE(dev, r, "couldn't find PHY provider device resource\n");
 }
 EXPORT_SYMBOL_GPL(devm_of_phy_provider_unregister);
+#endif
 
 /**
  * phy_release() - release the phy
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index a810f2a18842..184a61167ff6 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -138,32 +138,14 @@  struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
-struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
-			    const char *con_id);
-struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
-				     int index);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
-struct phy *of_phy_get(struct device_node *np, const char *con_id);
-struct phy *of_phy_simple_xlate(struct device *dev,
-	struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, struct device_node *node,
 		       const struct phy_ops *ops);
 struct phy *devm_phy_create(struct device *dev, struct device_node *node,
 			    const struct phy_ops *ops);
 void phy_destroy(struct phy *phy);
 void devm_phy_destroy(struct device *dev, struct phy *phy);
-struct phy_provider *__of_phy_provider_register(struct device *dev,
-	struct device_node *children, struct module *owner,
-	struct phy * (*of_xlate)(struct device *dev,
-				 struct of_phandle_args *args));
-struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
-	struct device_node *children, struct module *owner,
-	struct phy * (*of_xlate)(struct device *dev,
-				 struct of_phandle_args *args));
-void of_phy_provider_unregister(struct phy_provider *phy_provider);
-void devm_of_phy_provider_unregister(struct device *dev,
-	struct phy_provider *phy_provider);
 int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
 void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id);
 #else
@@ -265,20 +247,6 @@  static inline struct phy *devm_phy_optional_get(struct device *dev,
 	return ERR_PTR(-ENOSYS);
 }
 
-static inline struct phy *devm_of_phy_get(struct device *dev,
-					  struct device_node *np,
-					  const char *con_id)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
-static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
-						   struct device_node *np,
-						   int index)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
 static inline void phy_put(struct phy *phy)
 {
 }
@@ -287,17 +255,6 @@  static inline void devm_phy_put(struct device *dev, struct phy *phy)
 {
 }
 
-static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
-static inline struct phy *of_phy_simple_xlate(struct device *dev,
-	struct of_phandle_args *args)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
 static inline struct phy *phy_create(struct device *dev,
 				     struct device_node *node,
 				     const struct phy_ops *ops)
@@ -320,6 +277,35 @@  static inline void devm_phy_destroy(struct device *dev, struct phy *phy)
 {
 }
 
+static inline int
+phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
+{
+	return 0;
+}
+static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
+				     const char *dev_id) { }
+#endif
+
+#if defined(CONFIG_GENERIC_PHY) && defined(CONFIG_OF)
+struct phy_provider *__of_phy_provider_register(struct device *dev,
+	struct device_node *children, struct module *owner,
+	struct phy * (*of_xlate)(struct device *dev,
+				 struct of_phandle_args *args));
+struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
+	struct device_node *children, struct module *owner,
+	struct phy * (*of_xlate)(struct device *dev,
+				 struct of_phandle_args *args));
+void of_phy_provider_unregister(struct phy_provider *phy_provider);
+void devm_of_phy_provider_unregister(struct device *dev,
+	struct phy_provider *phy_provider);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+			    const char *con_id);
+struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
+				     int index);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
+struct phy *of_phy_simple_xlate(struct device *dev,
+	struct of_phandle_args *args);
+#else
 static inline struct phy_provider *__of_phy_provider_register(
 	struct device *dev, struct device_node *children, struct module *owner,
 	struct phy * (*of_xlate)(struct device *dev,
@@ -344,13 +330,32 @@  static inline void devm_of_phy_provider_unregister(struct device *dev,
 	struct phy_provider *phy_provider)
 {
 }
-static inline int
-phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
+
+static inline struct phy *devm_of_phy_get(struct device *dev,
+					  struct device_node *np,
+					  const char *con_id)
 {
-	return 0;
+	return ERR_PTR(-ENOSYS);
 }
-static inline void phy_remove_lookup(struct phy *phy, const char *con_id,
-				     const char *dev_id) { }
+
+static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
+						   struct device_node *np,
+						   int index)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+static inline struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+static inline struct phy *of_phy_simple_xlate(struct device *dev,
+	struct of_phandle_args *args)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
 #endif
 
 #endif /* __DRIVERS_PHY_H */