netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: Fix modular PHYLIB build
@ 2018-04-27 19:41 Florian Fainelli
  2018-04-28 20:27 ` Marcelo Ricardo Leitner
  2018-04-28 20:51 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2018-04-27 19:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, Florian Fainelli

After commit c59530d0d5dc ("net: Move PHY statistics code into PHY
library helpers") we made net/core/ethtool.c reference symbols which are
part of the library which can be modular. David introduced a temporary
fix with 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
which would prevent such modularity.

This is not desireable of course, so instead, just inline the functions
into include/linux/phy.h to keep both options available.

Fixes: c59530d0d5dc ("net: Move PHY statistics code into PHY library helpers")
Fixes: 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/Kconfig |  3 ++-
 drivers/net/phy/phy.c   | 48 -----------------------------------------------
 include/linux/phy.h     | 50 +++++++++++++++++++++++++++++++++++++------------
 3 files changed, 40 insertions(+), 61 deletions(-)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 7c5e8c1e9370..edb8b9ab827f 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -9,6 +9,7 @@ menuconfig MDIO_DEVICE
 
 config MDIO_BUS
 	tristate
+	default m if PHYLIB=m
 	default MDIO_DEVICE
 	help
 	  This internal symbol is used for link time dependencies and it
@@ -170,7 +171,7 @@ config PHYLINK
 	  autonegotiation modes.
 
 menuconfig PHYLIB
-	bool "PHY Device support and infrastructure"
+	tristate "PHY Device support and infrastructure"
 	depends on NETDEVICES
 	select MDIO_DEVICE
 	help
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a98ed12c0009..05c1e8ef15e6 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1277,51 +1277,3 @@ int phy_ethtool_nway_reset(struct net_device *ndev)
 	return phy_restart_aneg(phydev);
 }
 EXPORT_SYMBOL(phy_ethtool_nway_reset);
-
-int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
-{
-	if (!phydev->drv)
-		return -EIO;
-
-	mutex_lock(&phydev->lock);
-	phydev->drv->get_strings(phydev, data);
-	mutex_unlock(&phydev->lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(phy_ethtool_get_strings);
-
-int phy_ethtool_get_sset_count(struct phy_device *phydev)
-{
-	int ret;
-
-	if (!phydev->drv)
-		return -EIO;
-
-	if (phydev->drv->get_sset_count &&
-	    phydev->drv->get_strings &&
-	    phydev->drv->get_stats) {
-		mutex_lock(&phydev->lock);
-		ret = phydev->drv->get_sset_count(phydev);
-		mutex_unlock(&phydev->lock);
-
-		return ret;
-	}
-
-	return -EOPNOTSUPP;
-}
-EXPORT_SYMBOL(phy_ethtool_get_sset_count);
-
-int phy_ethtool_get_stats(struct phy_device *phydev,
-			  struct ethtool_stats *stats, u64 *data)
-{
-	if (!phydev->drv)
-		return -EIO;
-
-	mutex_lock(&phydev->lock);
-	phydev->drv->get_stats(phydev, stats, data);
-	mutex_unlock(&phydev->lock);
-
-	return 0;
-}
-EXPORT_SYMBOL(phy_ethtool_get_stats);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6ca81395c545..073235e70442 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1066,27 +1066,53 @@ int phy_ethtool_nway_reset(struct net_device *ndev);
 #if IS_ENABLED(CONFIG_PHYLIB)
 int __init mdio_bus_init(void);
 void mdio_bus_exit(void);
-int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data);
-int phy_ethtool_get_sset_count(struct phy_device *phydev);
-int phy_ethtool_get_stats(struct phy_device *phydev,
-			  struct ethtool_stats *stats, u64 *data);
-#else
-int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
+#endif
+
+/* Inline function for use within net/core/ethtool.c (built-in) */
+static inline int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data)
 {
-	return -EOPNOTSUPP;
+	if (!phydev->drv)
+		return -EIO;
+
+	mutex_lock(&phydev->lock);
+	phydev->drv->get_strings(phydev, data);
+	mutex_unlock(&phydev->lock);
+
+	return 0;
 }
 
-int phy_ethtool_get_sset_count(struct phy_device *phydev)
+static inline int phy_ethtool_get_sset_count(struct phy_device *phydev)
 {
+	int ret;
+
+	if (!phydev->drv)
+		return -EIO;
+
+	if (phydev->drv->get_sset_count &&
+	    phydev->drv->get_strings &&
+	    phydev->drv->get_stats) {
+		mutex_lock(&phydev->lock);
+		ret = phydev->drv->get_sset_count(phydev);
+		mutex_unlock(&phydev->lock);
+
+		return ret;
+	}
+
 	return -EOPNOTSUPP;
 }
 
-int phy_ethtool_get_stats(struct phy_device *phydev,
-			  struct ethtool_stats *stats, u64 *data)
+static inline int phy_ethtool_get_stats(struct phy_device *phydev,
+					struct ethtool_stats *stats, u64 *data)
 {
-	return -EOPNOTSUPP;
+	if (!phydev->drv)
+		return -EIO;
+
+	mutex_lock(&phydev->lock);
+	phydev->drv->get_stats(phydev, stats, data);
+	mutex_unlock(&phydev->lock);
+
+	return 0;
 }
-#endif
 
 extern struct bus_type mdio_bus_type;
 
-- 
2.14.1

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

* Re: [PATCH net-next] net: phy: Fix modular PHYLIB build
  2018-04-27 19:41 [PATCH net-next] net: phy: Fix modular PHYLIB build Florian Fainelli
@ 2018-04-28 20:27 ` Marcelo Ricardo Leitner
  2018-04-28 20:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2018-04-28 20:27 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, davem, andrew

On Fri, Apr 27, 2018 at 12:41:49PM -0700, Florian Fainelli wrote:
> After commit c59530d0d5dc ("net: Move PHY statistics code into PHY
> library helpers") we made net/core/ethtool.c reference symbols which are
> part of the library which can be modular. David introduced a temporary
> fix with 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
> which would prevent such modularity.
>
> This is not desireable of course, so instead, just inline the functions
> into include/linux/phy.h to keep both options available.
>
> Fixes: c59530d0d5dc ("net: Move PHY statistics code into PHY library helpers")
> Fixes: 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Confirmed that this also fixes the build when CONFIG_PHYLIB is off.
Thanks.

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

* Re: [PATCH net-next] net: phy: Fix modular PHYLIB build
  2018-04-27 19:41 [PATCH net-next] net: phy: Fix modular PHYLIB build Florian Fainelli
  2018-04-28 20:27 ` Marcelo Ricardo Leitner
@ 2018-04-28 20:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-04-28 20:51 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, andrew

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri, 27 Apr 2018 12:41:49 -0700

> After commit c59530d0d5dc ("net: Move PHY statistics code into PHY
> library helpers") we made net/core/ethtool.c reference symbols which are
> part of the library which can be modular. David introduced a temporary
> fix with 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
> which would prevent such modularity.
> 
> This is not desireable of course, so instead, just inline the functions
> into include/linux/phy.h to keep both options available.
> 
> Fixes: c59530d0d5dc ("net: Move PHY statistics code into PHY library helpers")
> Fixes: 1ecd6e8ad996 ("phy: Temporary build fix after phylib changes.")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks Florian.

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

end of thread, other threads:[~2018-04-28 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-27 19:41 [PATCH net-next] net: phy: Fix modular PHYLIB build Florian Fainelli
2018-04-28 20:27 ` Marcelo Ricardo Leitner
2018-04-28 20:51 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).