Now that all PHY drivers that support downstream SFP have been converted
to phy_port serdes handling, we can make the generic PHY SFP handling
mandatory, thus making all phylib sfp helpers static.
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
drivers/net/phy/phy_device.c | 28 +++++++++-------------------
include/linux/phy.h | 6 ------
2 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4aac9644c25c..9ae9607e0cd4 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1354,7 +1354,7 @@ static DEVICE_ATTR_RO(phy_standalone);
*
* Return: 0 on success, otherwise a negative error code.
*/
-int phy_sfp_connect_phy(void *upstream, struct phy_device *phy)
+static int phy_sfp_connect_phy(void *upstream, struct phy_device *phy)
{
struct phy_device *phydev = upstream;
struct net_device *dev = phydev->attached_dev;
@@ -1364,7 +1364,6 @@ int phy_sfp_connect_phy(void *upstream, struct phy_device *phy)
return 0;
}
-EXPORT_SYMBOL(phy_sfp_connect_phy);
/**
* phy_sfp_disconnect_phy - Disconnect the SFP module's PHY from the upstream PHY
@@ -1376,7 +1375,7 @@ EXPORT_SYMBOL(phy_sfp_connect_phy);
* will be destroyed, re-inserting the same module will add a new phy with a
* new index.
*/
-void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy)
+static void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy)
{
struct phy_device *phydev = upstream;
struct net_device *dev = phydev->attached_dev;
@@ -1384,7 +1383,6 @@ void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy)
if (dev)
phy_link_topo_del_phy(dev, phy);
}
-EXPORT_SYMBOL(phy_sfp_disconnect_phy);
/**
* phy_sfp_attach - attach the SFP bus to the PHY upstream network device
@@ -1393,7 +1391,7 @@ EXPORT_SYMBOL(phy_sfp_disconnect_phy);
*
* This is used to fill in the sfp_upstream_ops .attach member.
*/
-void phy_sfp_attach(void *upstream, struct sfp_bus *bus)
+static void phy_sfp_attach(void *upstream, struct sfp_bus *bus)
{
struct phy_device *phydev = upstream;
@@ -1401,7 +1399,6 @@ void phy_sfp_attach(void *upstream, struct sfp_bus *bus)
phydev->attached_dev->sfp_bus = bus;
phydev->sfp_bus_attached = true;
}
-EXPORT_SYMBOL(phy_sfp_attach);
/**
* phy_sfp_detach - detach the SFP bus from the PHY upstream network device
@@ -1410,7 +1407,7 @@ EXPORT_SYMBOL(phy_sfp_attach);
*
* This is used to fill in the sfp_upstream_ops .detach member.
*/
-void phy_sfp_detach(void *upstream, struct sfp_bus *bus)
+static void phy_sfp_detach(void *upstream, struct sfp_bus *bus)
{
struct phy_device *phydev = upstream;
@@ -1418,7 +1415,6 @@ void phy_sfp_detach(void *upstream, struct sfp_bus *bus)
phydev->attached_dev->sfp_bus = NULL;
phydev->sfp_bus_attached = false;
}
-EXPORT_SYMBOL(phy_sfp_detach);
static int phy_sfp_module_insert(void *upstream, const struct sfp_eeprom_id *id)
{
@@ -1561,10 +1557,8 @@ static int phy_setup_sfp_port(struct phy_device *phydev)
/**
* phy_sfp_probe - probe for a SFP cage attached to this PHY device
* @phydev: Pointer to phy_device
- * @ops: SFP's upstream operations
*/
-int phy_sfp_probe(struct phy_device *phydev,
- const struct sfp_upstream_ops *ops)
+static int phy_sfp_probe(struct phy_device *phydev)
{
struct sfp_bus *bus;
int ret = 0;
@@ -1576,7 +1570,7 @@ int phy_sfp_probe(struct phy_device *phydev,
phydev->sfp_bus = bus;
- ret = sfp_bus_add_upstream(bus, phydev, ops);
+ ret = sfp_bus_add_upstream(bus, phydev, &sfp_phydev_ops);
sfp_bus_put(bus);
}
@@ -1585,7 +1579,6 @@ int phy_sfp_probe(struct phy_device *phydev,
return ret;
}
-EXPORT_SYMBOL(phy_sfp_probe);
static bool phy_drv_supports_irq(const struct phy_driver *phydrv)
{
@@ -3635,12 +3628,9 @@ static int phy_setup_ports(struct phy_device *phydev)
if (ret)
return ret;
- /* Use generic SFP probing only if the driver didn't do so already */
- if (!phydev->sfp_bus) {
- ret = phy_sfp_probe(phydev, &sfp_phydev_ops);
- if (ret)
- goto out;
- }
+ ret = phy_sfp_probe(phydev);
+ if (ret)
+ goto out;
if (phydev->n_ports < phydev->max_n_ports) {
ret = phy_default_setup_single_port(phydev);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index b850af2500e4..12cf2d81567c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1909,12 +1909,6 @@ int phy_suspend(struct phy_device *phydev);
int phy_resume(struct phy_device *phydev);
int __phy_resume(struct phy_device *phydev);
int phy_loopback(struct phy_device *phydev, bool enable);
-int phy_sfp_connect_phy(void *upstream, struct phy_device *phy);
-void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy);
-void phy_sfp_attach(void *upstream, struct sfp_bus *bus);
-void phy_sfp_detach(void *upstream, struct sfp_bus *bus);
-int phy_sfp_probe(struct phy_device *phydev,
- const struct sfp_upstream_ops *ops);
struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
phy_interface_t interface);
struct phy_device *phy_find_first(struct mii_bus *bus);
--
2.48.1
Hi Maxime,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Chevallier/net-ethtool-Introduce-ETHTOOL_LINK_MEDIUM_-values/20250208-064223
base: net-next/main
patch link: https://lore.kernel.org/r/20250207223634.600218-12-maxime.chevallier%40bootlin.com
patch subject: [PATCH net-next 11/13] net: phy: Only rely on phy_port for PHY-driven SFP
config: i386-buildonly-randconfig-005-20250208 (https://download.01.org/0day-ci/archive/20250208/202502082347.tFufJ529-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250208/202502082347.tFufJ529-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502082347.tFufJ529-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/net/phy/qcom/qca807x.c:698:12: error: use of undeclared identifier 'phy_sfp_attach'; did you mean 'phy_attach'?
698 | .attach = phy_sfp_attach,
| ^~~~~~~~~~~~~~
| phy_attach
include/linux/phy.h:1912:20: note: 'phy_attach' declared here
1912 | struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
| ^
>> drivers/net/phy/qcom/qca807x.c:699:12: error: use of undeclared identifier 'phy_sfp_detach'; did you mean 'phy_detach'?
699 | .detach = phy_sfp_detach,
| ^~~~~~~~~~~~~~
| phy_detach
include/linux/phy.h:1924:6: note: 'phy_detach' declared here
1924 | void phy_detach(struct phy_device *phydev);
| ^
>> drivers/net/phy/qcom/qca807x.c:702:17: error: use of undeclared identifier 'phy_sfp_connect_phy'
702 | .connect_phy = phy_sfp_connect_phy,
| ^
>> drivers/net/phy/qcom/qca807x.c:703:20: error: use of undeclared identifier 'phy_sfp_disconnect_phy'
703 | .disconnect_phy = phy_sfp_disconnect_phy,
| ^
>> drivers/net/phy/qcom/qca807x.c:748:9: error: call to undeclared function 'phy_sfp_probe'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
748 | ret = phy_sfp_probe(phydev, &qca807x_sfp_ops);
| ^
5 errors generated.
vim +698 drivers/net/phy/qcom/qca807x.c
d1cb613efbd3cd Robert Marko 2024-02-06 696
d1cb613efbd3cd Robert Marko 2024-02-06 697 static const struct sfp_upstream_ops qca807x_sfp_ops = {
d1cb613efbd3cd Robert Marko 2024-02-06 @698 .attach = phy_sfp_attach,
d1cb613efbd3cd Robert Marko 2024-02-06 @699 .detach = phy_sfp_detach,
d1cb613efbd3cd Robert Marko 2024-02-06 700 .module_insert = qca807x_sfp_insert,
d1cb613efbd3cd Robert Marko 2024-02-06 701 .module_remove = qca807x_sfp_remove,
b2db6f4ace72e7 Maxime Chevallier 2024-08-21 @702 .connect_phy = phy_sfp_connect_phy,
b2db6f4ace72e7 Maxime Chevallier 2024-08-21 @703 .disconnect_phy = phy_sfp_disconnect_phy,
d1cb613efbd3cd Robert Marko 2024-02-06 704 };
d1cb613efbd3cd Robert Marko 2024-02-06 705
d1cb613efbd3cd Robert Marko 2024-02-06 706 static int qca807x_probe(struct phy_device *phydev)
d1cb613efbd3cd Robert Marko 2024-02-06 707 {
d1cb613efbd3cd Robert Marko 2024-02-06 708 struct device_node *node = phydev->mdio.dev.of_node;
d1cb613efbd3cd Robert Marko 2024-02-06 709 struct qca807x_shared_priv *shared_priv;
d1cb613efbd3cd Robert Marko 2024-02-06 710 struct device *dev = &phydev->mdio.dev;
d1cb613efbd3cd Robert Marko 2024-02-06 711 struct phy_package_shared *shared;
d1cb613efbd3cd Robert Marko 2024-02-06 712 struct qca807x_priv *priv;
d1cb613efbd3cd Robert Marko 2024-02-06 713 int ret;
d1cb613efbd3cd Robert Marko 2024-02-06 714
d1cb613efbd3cd Robert Marko 2024-02-06 715 ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));
d1cb613efbd3cd Robert Marko 2024-02-06 716 if (ret)
d1cb613efbd3cd Robert Marko 2024-02-06 717 return ret;
d1cb613efbd3cd Robert Marko 2024-02-06 718
d1cb613efbd3cd Robert Marko 2024-02-06 719 if (phy_package_probe_once(phydev)) {
d1cb613efbd3cd Robert Marko 2024-02-06 720 ret = qca807x_phy_package_probe_once(phydev);
d1cb613efbd3cd Robert Marko 2024-02-06 721 if (ret)
d1cb613efbd3cd Robert Marko 2024-02-06 722 return ret;
d1cb613efbd3cd Robert Marko 2024-02-06 723 }
d1cb613efbd3cd Robert Marko 2024-02-06 724
d1cb613efbd3cd Robert Marko 2024-02-06 725 shared = phydev->shared;
d1cb613efbd3cd Robert Marko 2024-02-06 726 shared_priv = shared->priv;
d1cb613efbd3cd Robert Marko 2024-02-06 727
d1cb613efbd3cd Robert Marko 2024-02-06 728 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
d1cb613efbd3cd Robert Marko 2024-02-06 729 if (!priv)
d1cb613efbd3cd Robert Marko 2024-02-06 730 return -ENOMEM;
d1cb613efbd3cd Robert Marko 2024-02-06 731
d1cb613efbd3cd Robert Marko 2024-02-06 732 priv->dac_full_amplitude = of_property_read_bool(node, "qcom,dac-full-amplitude");
d1cb613efbd3cd Robert Marko 2024-02-06 733 priv->dac_full_bias_current = of_property_read_bool(node, "qcom,dac-full-bias-current");
d1cb613efbd3cd Robert Marko 2024-02-06 734 priv->dac_disable_bias_current_tweak = of_property_read_bool(node,
d1cb613efbd3cd Robert Marko 2024-02-06 735 "qcom,dac-disable-bias-current-tweak");
d1cb613efbd3cd Robert Marko 2024-02-06 736
1677293ed89166 Robert Marko 2024-03-05 737 #if IS_ENABLED(CONFIG_GPIOLIB)
d1cb613efbd3cd Robert Marko 2024-02-06 738 /* Do not register a GPIO controller unless flagged for it */
d1cb613efbd3cd Robert Marko 2024-02-06 739 if (of_property_read_bool(node, "gpio-controller")) {
d1cb613efbd3cd Robert Marko 2024-02-06 740 ret = qca807x_gpio(phydev);
d1cb613efbd3cd Robert Marko 2024-02-06 741 if (ret)
d1cb613efbd3cd Robert Marko 2024-02-06 742 return ret;
d1cb613efbd3cd Robert Marko 2024-02-06 743 }
1677293ed89166 Robert Marko 2024-03-05 744 #endif
d1cb613efbd3cd Robert Marko 2024-02-06 745
d1cb613efbd3cd Robert Marko 2024-02-06 746 /* Attach SFP bus on combo port*/
d1cb613efbd3cd Robert Marko 2024-02-06 747 if (phy_read(phydev, QCA807X_CHIP_CONFIGURATION)) {
d1cb613efbd3cd Robert Marko 2024-02-06 @748 ret = phy_sfp_probe(phydev, &qca807x_sfp_ops);
d1cb613efbd3cd Robert Marko 2024-02-06 749 if (ret)
d1cb613efbd3cd Robert Marko 2024-02-06 750 return ret;
d1cb613efbd3cd Robert Marko 2024-02-06 751 linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported);
d1cb613efbd3cd Robert Marko 2024-02-06 752 linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->advertising);
d1cb613efbd3cd Robert Marko 2024-02-06 753 }
d1cb613efbd3cd Robert Marko 2024-02-06 754
d1cb613efbd3cd Robert Marko 2024-02-06 755 phydev->priv = priv;
d1cb613efbd3cd Robert Marko 2024-02-06 756
d1cb613efbd3cd Robert Marko 2024-02-06 757 return 0;
d1cb613efbd3cd Robert Marko 2024-02-06 758 }
d1cb613efbd3cd Robert Marko 2024-02-06 759
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi, On Sun, 9 Feb 2025 00:04:55 +0800 kernel test robot <lkp@intel.com> wrote: > Hi Maxime, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on net-next/main] > > url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Chevallier/net-ethtool-Introduce-ETHTOOL_LINK_MEDIUM_-values/20250208-064223 > base: net-next/main > patch link: https://lore.kernel.org/r/20250207223634.600218-12-maxime.chevallier%40bootlin.com > patch subject: [PATCH net-next 11/13] net: phy: Only rely on phy_port for PHY-driven SFP > config: i386-buildonly-randconfig-005-20250208 (https://download.01.org/0day-ci/archive/20250208/202502082347.tFufJ529-lkp@intel.com/config) > compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250208/202502082347.tFufJ529-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202502082347.tFufJ529-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > >> drivers/net/phy/qcom/qca807x.c:698:12: error: use of undeclared identifier 'phy_sfp_attach'; did you mean 'phy_attach'? > 698 | .attach = phy_sfp_attach, > | ^~~~~~~~~~~~~~ > | phy_attach > include/linux/phy.h:1912:20: note: 'phy_attach' declared here > 1912 | struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, > | ^ > >> drivers/net/phy/qcom/qca807x.c:699:12: error: use of undeclared identifier 'phy_sfp_detach'; did you mean 'phy_detach'? > 699 | .detach = phy_sfp_detach, > | ^~~~~~~~~~~~~~ > | phy_detach > include/linux/phy.h:1924:6: note: 'phy_detach' declared here > 1924 | void phy_detach(struct phy_device *phydev); > | ^ > >> drivers/net/phy/qcom/qca807x.c:702:17: error: use of undeclared identifier 'phy_sfp_connect_phy' > 702 | .connect_phy = phy_sfp_connect_phy, > | ^ > >> drivers/net/phy/qcom/qca807x.c:703:20: error: use of undeclared identifier 'phy_sfp_disconnect_phy' > 703 | .disconnect_phy = phy_sfp_disconnect_phy, > | ^ > >> drivers/net/phy/qcom/qca807x.c:748:9: error: call to undeclared function 'phy_sfp_probe'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > 748 | ret = phy_sfp_probe(phydev, &qca807x_sfp_ops); > | ^ > 5 errors generated. Ah damned, I missed that qca807x now also supports SFP. I'll include a conversion fr that driver too in V2 (and add Robert in CC:) Thanks, Maxime
© 2016 - 2026 Red Hat, Inc.