Skip to contentSkip to conversation

net: phy: clean up phy.h

PATCH Applied Heiner Kallweit 5 participants 16 messages Feb 13, 2025 – Feb 15, 2025

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: clean up phy.h

This series is a starting point to clean up phy.h and remove definitions which are phylib-internal.

Heiner Kallweit (4):
net: phy: remove fixup-related definitions from phy.h which are not
used outside phylib
net: phy: stop exporting feature arrays which aren't used outside
phylib
net: phy: stop exporting phy_queue_state_machine
net: phy: remove helper phy_is_internal

 drivers/net/phy/phy.c        |  6 +++---
 drivers/net/phy/phy_device.c | 40 ++++++++++++++++++------------------
 include/linux/phy.h          | 29 --------------------------
 3 files changed, 23 insertions(+), 52 deletions(-)
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 1/4 net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

Certain fixup-related definitions aren't used outside phy_device.c. So make them private and remove them from phy.h.

---
 drivers/net/phy/phy_device.c | 16 +++++++++++++---
 include/linux/phy.h          | 14 --------------
 2 files changed, 13 insertions(+), 17 deletions(-)
drivers/net/phy/phy_device.c +13 -3
index 9b06ba92f..14c312ad2 100644
@@ -45,6 +45,17 @@ MODULE_DESCRIPTION("PHY library");
 MODULE_AUTHOR("Andy Fleming");
 MODULE_LICENSE("GPL");
 
+#define	PHY_ANY_ID	"MATCH ANY PHY"
+#define	PHY_ANY_UID	0xffffffff
+
+struct phy_fixup {
+	struct list_head list;
+	char bus_id[MII_BUS_ID_SIZE + 3];
+	u32 phy_uid;
+	u32 phy_uid_mask;
+	int (*run)(struct phy_device *phydev);
+};
+
 __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_features) __ro_after_init;
 EXPORT_SYMBOL_GPL(phy_basic_features);
 
@@ -378,8 +389,8 @@ static SIMPLE_DEV_PM_OPS(mdio_bus_phy_pm_ops, mdio_bus_phy_suspend,
  *	comparison
  * @run: The actual code to be run when a matching PHY is found
  */
-int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-		       int (*run)(struct phy_device *))
+static int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+			      int (*run)(struct phy_device *))
 {
 	struct phy_fixup *fixup = kzalloc(sizeof(*fixup), GFP_KERNEL);
 
@@ -397,7 +408,6 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
 
 	return 0;
 }
-EXPORT_SYMBOL(phy_register_fixup);
 
 /* Registers a fixup to be run on any PHY with the UID in phy_uid */
 int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
include/linux/phy.h +0 -14
index 29df4c602..96e427c2c 100644
@@ -1277,9 +1277,6 @@ struct phy_driver {
 #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d),		\
 				      struct phy_driver, mdiodrv)
 
-#define PHY_ANY_ID "MATCH ANY PHY"
-#define PHY_ANY_UID 0xffffffff
-
 #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0)
 #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4)
 #define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10)
@@ -1312,15 +1309,6 @@ static inline bool phydev_id_compare(struct phy_device *phydev, u32 id)
 	return phy_id_compare(id, phydev->phy_id, phydev->drv->phy_id_mask);
 }
 
-/* A Structure for boards to register fixups with the PHY Lib */
-struct phy_fixup {
-	struct list_head list;
-	char bus_id[MII_BUS_ID_SIZE + 3];
-	u32 phy_uid;
-	u32 phy_uid_mask;
-	int (*run)(struct phy_device *phydev);
-};
-
 const char *phy_speed_to_str(int speed);
 const char *phy_duplex_to_str(unsigned int duplex);
 const char *phy_rate_matching_to_str(int rate_matching);
@@ -2117,8 +2105,6 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
 void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
 		       bool *tx_pause, bool *rx_pause);
 
-int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-		       int (*run)(struct phy_device *));
 int phy_register_fixup_for_id(const char *bus_id,
 			      int (*run)(struct phy_device *));
 int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
Signature · 1 line
2.48.1
author maintainer
#6 lore raw

PATCH 2/4 net: phy: stop exporting feature arrays which aren't used outside phylib

In reply to Heiner Kallweit

Stop exporting feature arrays which aren't used outside phylib.

---
 drivers/net/phy/phy_device.c | 22 ++++++----------------
 include/linux/phy.h          |  5 -----
 2 files changed, 6 insertions(+), 21 deletions(-)
drivers/net/phy/phy_device.c +6 -16
index 14c312ad2..1c10c774b 100644
@@ -91,37 +91,28 @@ static const int phy_all_ports_features_array[7] = {
 	ETHTOOL_LINK_MODE_Backplane_BIT,
 };
 
-const int phy_10_100_features_array[4] = {
+static const int phy_10_100_features_array[4] = {
 	ETHTOOL_LINK_MODE_10baseT_Half_BIT,
 	ETHTOOL_LINK_MODE_10baseT_Full_BIT,
 	ETHTOOL_LINK_MODE_100baseT_Half_BIT,
 	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
 };
-EXPORT_SYMBOL_GPL(phy_10_100_features_array);
 
-const int phy_basic_t1_features_array[3] = {
+static const int phy_basic_t1_features_array[3] = {
 	ETHTOOL_LINK_MODE_TP_BIT,
 	ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
 	ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
 };
-EXPORT_SYMBOL_GPL(phy_basic_t1_features_array);
 
-const int phy_basic_t1s_p2mp_features_array[2] = {
+static const int phy_basic_t1s_p2mp_features_array[2] = {
 	ETHTOOL_LINK_MODE_TP_BIT,
 	ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT,
 };
-EXPORT_SYMBOL_GPL(phy_basic_t1s_p2mp_features_array);
 
-const int phy_gbit_features_array[2] = {
+static const int phy_gbit_features_array[2] = {
 	ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
 	ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
 };
-EXPORT_SYMBOL_GPL(phy_gbit_features_array);
-
-const int phy_10gbit_features_array[1] = {
-	ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
-};
-EXPORT_SYMBOL_GPL(phy_10gbit_features_array);
 
 static const int phy_eee_cap1_features_array[] = {
 	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
@@ -196,9 +187,8 @@ static void features_init(void)
 	linkmode_set_bit_array(phy_gbit_features_array,
 			       ARRAY_SIZE(phy_gbit_features_array),
 			       phy_10gbit_features);
-	linkmode_set_bit_array(phy_10gbit_features_array,
-			       ARRAY_SIZE(phy_10gbit_features_array),
-			       phy_10gbit_features);
+	linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
+			 phy_10gbit_features);
 
 	linkmode_set_bit_array(phy_eee_cap1_features_array,
 			       ARRAY_SIZE(phy_eee_cap1_features_array),
include/linux/phy.h +0 -5
index 96e427c2c..33e2c2c93 100644
@@ -54,11 +54,6 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap2_features) __ro_after_init;
 #define PHY_EEE_CAP2_FEATURES ((unsigned long *)&phy_eee_cap2_features)
 
 extern const int phy_basic_ports_array[3];
-extern const int phy_10_100_features_array[4];
-extern const int phy_basic_t1_features_array[3];
-extern const int phy_basic_t1s_p2mp_features_array[2];
-extern const int phy_gbit_features_array[2];
-extern const int phy_10gbit_features_array[1];
 
 /*
  * Set phydev->irq to PHY_POLL if interrupts are not supported,
Signature · 1 line
2.48.1
author maintainer
#9 lore raw

PATCH 3/4 net: phy: stop exporting phy_queue_state_machine

In reply to Heiner Kallweit

phy_queue_state_machine() isn't used outside phy.c, so stop exporting it.

---
 drivers/net/phy/phy.c | 4 ++--
 include/linux/phy.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/phy.c +2 -2
index d0c1718e2..8738ffb4c 100644
@@ -520,12 +520,12 @@ int __phy_hwtstamp_set(struct phy_device *phydev,
  * @phydev: the phy_device struct
  * @jiffies: Run the state machine after these jiffies
  */
-void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
+static void phy_queue_state_machine(struct phy_device *phydev,
+				    unsigned long jiffies)
 {
 	mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 			 jiffies);
 }
-EXPORT_SYMBOL(phy_queue_state_machine);
 
 /**
  * phy_trigger_machine - Trigger the state machine to run now
include/linux/phy.h +0 -1
index 33e2c2c93..bb7454364 100644
@@ -2061,7 +2061,6 @@ int phy_drivers_register(struct phy_driver *new_driver, int n,
 			 struct module *owner);
 void phy_error(struct phy_device *phydev);
 void phy_state_machine(struct work_struct *work);
-void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies);
 void phy_trigger_machine(struct phy_device *phydev);
 void phy_mac_interrupt(struct phy_device *phydev);
 void phy_start_machine(struct phy_device *phydev);
Signature · 1 line
2.48.1
author maintainer
#12 lore raw

PATCH 4/4 net: phy: remove helper phy_is_internal

In reply to Heiner Kallweit

Helper phy_is_internal() is just used in two places phylib-internally. So let's remove it from the API.

---
 drivers/net/phy/phy.c        | 2 +-
 drivers/net/phy/phy_device.c | 2 +-
 include/linux/phy.h          | 9 ---------
 3 files changed, 2 insertions(+), 11 deletions(-)
drivers/net/phy/phy.c +1 -1
index 8738ffb4c..77b3fb843 100644
@@ -302,7 +302,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
 		cmd->base.port = PORT_BNC;
 	else
 		cmd->base.port = phydev->port;
-	cmd->base.transceiver = phy_is_internal(phydev) ?
+	cmd->base.transceiver = phydev->is_internal ?
 				XCVR_INTERNAL : XCVR_EXTERNAL;
 	cmd->base.phy_address = phydev->mdio.addr;
 	cmd->base.autoneg = phydev->autoneg;
drivers/net/phy/phy_device.c +1 -1
index 1c10c774b..35ec99b4d 100644
@@ -544,7 +544,7 @@ phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
 	struct phy_device *phydev = to_phy_device(dev);
 	const char *mode = NULL;
 
-	if (phy_is_internal(phydev))
+	if (phydev->is_internal)
 		mode = "internal";
 	else
 		mode = phy_modes(phydev->interface);
include/linux/phy.h +0 -9
index bb7454364..8efbf62d8 100644
@@ -1729,15 +1729,6 @@ static inline bool phy_is_default_hwtstamp(struct phy_device *phydev)
 	return phy_has_hwtstamp(phydev) && phydev->default_timestamp;
 }
 
-/**
- * phy_is_internal - Convenience function for testing if a PHY is internal
- * @phydev: the phy_device struct
- */
-static inline bool phy_is_internal(struct phy_device *phydev)
-{
-	return phydev->is_internal;
-}
-
 /**
  * phy_on_sfp - Convenience function for testing if a PHY is on an SFP module
  * @phydev: the phy_device struct
Signature · 1 line
2.48.1
#2 lore raw

Re: [PATCH net-next 1/4] net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

In reply to Heiner Kallweit
Quoted 14 lines · Heiner Kallweit

Certain fixup-related definitions aren't used outside phy_device.c. So make them private and remove them from phy.h.

---
  drivers/net/phy/phy_device.c | 16 +++++++++++++---
  include/linux/phy.h          | 14 --------------
  2 files changed, 13 insertions(+), 17 deletions(-)
drivers/net/phy/phy_device.c +0 -0
index 9b06ba92f..14c312ad2 100644

drivers/net/phy/phy_device.c MODULE_DESCRIPTION("PHY library"); · line 50

Quoted 6 lines
drivers/net/phy/phy_device.c +3 -0
@@ -45,6 +45,17 @@ MODULE_DESCRIPTION("PHY library");
  MODULE_AUTHOR("Andy Fleming");
  MODULE_LICENSE("GPL");
 
+#define	PHY_ANY_ID	"MATCH ANY PHY"
+#define	PHY_ANY_UID	0xffffffff
+

Overall looks like a nice cleanup but I am not sure about this space between #define and PHY_ANY_ID or PHY_ANY_UID...

Quoted 69 lines
drivers/net/phy/phy_device.c +10 -3
+struct phy_fixup {
+	struct list_head list;
+	char bus_id[MII_BUS_ID_SIZE + 3];
+	u32 phy_uid;
+	u32 phy_uid_mask;
+	int (*run)(struct phy_device *phydev);
+};
+
  __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_features) __ro_after_init;
  EXPORT_SYMBOL_GPL(phy_basic_features);
 
@@ -378,8 +389,8 @@ static SIMPLE_DEV_PM_OPS(mdio_bus_phy_pm_ops, mdio_bus_phy_suspend,
   *	comparison
   * @run: The actual code to be run when a matching PHY is found
   */
-int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-		       int (*run)(struct phy_device *))
+static int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+			      int (*run)(struct phy_device *))
  {
  	struct phy_fixup *fixup = kzalloc(sizeof(*fixup), GFP_KERNEL);
 
@@ -397,7 +408,6 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
 
  	return 0;
  }
-EXPORT_SYMBOL(phy_register_fixup);
 
  /* Registers a fixup to be run on any PHY with the UID in phy_uid */
  int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
include/linux/phy.h +0 -14
index 29df4c602..96e427c2c 100644
@@ -1277,9 +1277,6 @@ struct phy_driver {
  #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d),		\
  				      struct phy_driver, mdiodrv)
 
-#define PHY_ANY_ID "MATCH ANY PHY"
-#define PHY_ANY_UID 0xffffffff
-
  #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0)
  #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4)
  #define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10)
@@ -1312,15 +1309,6 @@ static inline bool phydev_id_compare(struct phy_device *phydev, u32 id)
  	return phy_id_compare(id, phydev->phy_id, phydev->drv->phy_id_mask);
  }
 
-/* A Structure for boards to register fixups with the PHY Lib */
-struct phy_fixup {
-	struct list_head list;
-	char bus_id[MII_BUS_ID_SIZE + 3];
-	u32 phy_uid;
-	u32 phy_uid_mask;
-	int (*run)(struct phy_device *phydev);
-};
-
  const char *phy_speed_to_str(int speed);
  const char *phy_duplex_to_str(unsigned int duplex);
  const char *phy_rate_matching_to_str(int rate_matching);
@@ -2117,8 +2105,6 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
  void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
  		       bool *tx_pause, bool *rx_pause);
 
-int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-		       int (*run)(struct phy_device *));
  int phy_register_fixup_for_id(const char *bus_id,
  			      int (*run)(struct phy_device *));
  int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
Reviewed-by on v1 3/4
#10 lore raw

Re: [PATCH net-next 3/4] net: phy: stop exporting phy_queue_state_machine

In reply to Heiner Kallweit
Quoted 33 lines · Heiner Kallweit

phy_queue_state_machine() isn't used outside phy.c, so stop exporting it.

---
  drivers/net/phy/phy.c | 4 ++--
  include/linux/phy.h   | 1 -
  2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/phy.c +2 -2
index d0c1718e2..8738ffb4c 100644
@@ -520,12 +520,12 @@ int __phy_hwtstamp_set(struct phy_device *phydev,
   * @phydev: the phy_device struct
   * @jiffies: Run the state machine after these jiffies
   */
-void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
+static void phy_queue_state_machine(struct phy_device *phydev,
+				    unsigned long jiffies)
  {
  	mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,
  			 jiffies);
  }
-EXPORT_SYMBOL(phy_queue_state_machine);
 
  /**
   * phy_trigger_machine - Trigger the state machine to run now
include/linux/phy.h +0 -0
index 33e2c2c93..bb7454364 100644

include/linux/phy.h int phy_drivers_register(struct phy_driver *new_driver, int n, · line 2066

Quoted 7 lines
include/linux/phy.h +0 -1
@@ -2061,7 +2061,6 @@ int phy_drivers_register(struct phy_driver *new_driver, int n,
  			 struct module *owner);
  void phy_error(struct phy_device *phydev);
  void phy_state_machine(struct work_struct *work);
-void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies);
  void phy_trigger_machine(struct phy_device *phydev);
  void phy_mac_interrupt(struct phy_device *phydev);
  void phy_start_machine(struct phy_device *phydev);
Reviewed-by on v1 4/4
#13 lore raw

Re: [PATCH net-next 4/4] net: phy: remove helper phy_is_internal

In reply to Heiner Kallweit
Quoted 46 lines · Heiner Kallweit

Helper phy_is_internal() is just used in two places phylib-internally. So let's remove it from the API.

---
  drivers/net/phy/phy.c        | 2 +-
  drivers/net/phy/phy_device.c | 2 +-
  include/linux/phy.h          | 9 ---------
  3 files changed, 2 insertions(+), 11 deletions(-)
drivers/net/phy/phy.c +1 -1
index 8738ffb4c..77b3fb843 100644
@@ -302,7 +302,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
  		cmd->base.port = PORT_BNC;
  	else
  		cmd->base.port = phydev->port;
-	cmd->base.transceiver = phy_is_internal(phydev) ?
+	cmd->base.transceiver = phydev->is_internal ?
  				XCVR_INTERNAL : XCVR_EXTERNAL;
  	cmd->base.phy_address = phydev->mdio.addr;
  	cmd->base.autoneg = phydev->autoneg;
drivers/net/phy/phy_device.c +1 -1
index 1c10c774b..35ec99b4d 100644
@@ -544,7 +544,7 @@ phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
  	struct phy_device *phydev = to_phy_device(dev);
  	const char *mode = NULL;
 
-	if (phy_is_internal(phydev))
+	if (phydev->is_internal)
  		mode = "internal";
  	else
  		mode = phy_modes(phydev->interface);
include/linux/phy.h +0 -2
index bb7454364..8efbf62d8 100644
@@ -1729,15 +1729,6 @@ static inline bool phy_is_default_hwtstamp(struct phy_device *phydev)
  	return phy_has_hwtstamp(phydev) && phydev->default_timestamp;
  }
 
-/**
- * phy_is_internal - Convenience function for testing if a PHY is internal

include/linux/phy.h static inline bool phy_is_default_hwtstamp(struct phy_device *phydev) · line 1734

Quoted 10 lines
include/linux/phy.h +0 -7
- * @phydev: the phy_device struct
- */
-static inline bool phy_is_internal(struct phy_device *phydev)
-{
-	return phydev->is_internal;
-}
-
  /**
   * phy_on_sfp - Convenience function for testing if a PHY is on an SFP module
   * @phydev: the phy_device struct

Thanks for that change.

Reviewed-by on v1 2/4
#7 lore raw

Re: [PATCH net-next 2/4] net: phy: stop exporting feature arrays which aren't used outside phylib

In reply to Heiner Kallweit
Quoted 72 lines · Heiner Kallweit

Stop exporting feature arrays which aren't used outside phylib.

---
  drivers/net/phy/phy_device.c | 22 ++++++----------------
  include/linux/phy.h          |  5 -----
  2 files changed, 6 insertions(+), 21 deletions(-)
drivers/net/phy/phy_device.c +6 -16
index 14c312ad2..1c10c774b 100644
@@ -91,37 +91,28 @@ static const int phy_all_ports_features_array[7] = {
  	ETHTOOL_LINK_MODE_Backplane_BIT,
  };
 
-const int phy_10_100_features_array[4] = {
+static const int phy_10_100_features_array[4] = {
  	ETHTOOL_LINK_MODE_10baseT_Half_BIT,
  	ETHTOOL_LINK_MODE_10baseT_Full_BIT,
  	ETHTOOL_LINK_MODE_100baseT_Half_BIT,
  	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
  };
-EXPORT_SYMBOL_GPL(phy_10_100_features_array);
 
-const int phy_basic_t1_features_array[3] = {
+static const int phy_basic_t1_features_array[3] = {
  	ETHTOOL_LINK_MODE_TP_BIT,
  	ETHTOOL_LINK_MODE_10baseT1L_Full_BIT,
  	ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
  };
-EXPORT_SYMBOL_GPL(phy_basic_t1_features_array);
 
-const int phy_basic_t1s_p2mp_features_array[2] = {
+static const int phy_basic_t1s_p2mp_features_array[2] = {
  	ETHTOOL_LINK_MODE_TP_BIT,
  	ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT,
  };
-EXPORT_SYMBOL_GPL(phy_basic_t1s_p2mp_features_array);
 
-const int phy_gbit_features_array[2] = {
+static const int phy_gbit_features_array[2] = {
  	ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
  	ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
  };
-EXPORT_SYMBOL_GPL(phy_gbit_features_array);
-
-const int phy_10gbit_features_array[1] = {
-	ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
-};
-EXPORT_SYMBOL_GPL(phy_10gbit_features_array);
 
  static const int phy_eee_cap1_features_array[] = {
  	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
@@ -196,9 +187,8 @@ static void features_init(void)
  	linkmode_set_bit_array(phy_gbit_features_array,
  			       ARRAY_SIZE(phy_gbit_features_array),
  			       phy_10gbit_features);
-	linkmode_set_bit_array(phy_10gbit_features_array,
-			       ARRAY_SIZE(phy_10gbit_features_array),
-			       phy_10gbit_features);
+	linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
+			 phy_10gbit_features);
 
  	linkmode_set_bit_array(phy_eee_cap1_features_array,
  			       ARRAY_SIZE(phy_eee_cap1_features_array),
include/linux/phy.h +0 -0
index 96e427c2c..33e2c2c93 100644
@@ -54,11 +54,6 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap2_features) __ro_after_init;
  #define PHY_EEE_CAP2_FEATURES ((unsigned long *)&phy_eee_cap2_features)

include/linux/phy.h extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap2_features) __ro_after_init; · line 59

Quoted 10 lines
include/linux/phy.h +0 -5
 
  extern const int phy_basic_ports_array[3];
-extern const int phy_10_100_features_array[4];
-extern const int phy_basic_t1_features_array[3];
-extern const int phy_basic_t1s_p2mp_features_array[2];
-extern const int phy_gbit_features_array[2];
-extern const int phy_10gbit_features_array[1];
 
  /*
   * Set phydev->irq to PHY_POLL if interrupts are not supported,
author maintainer
#3 lore raw

Re: [PATCH net-next 1/4] net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

In reply to Mateusz Polchlopek
Quoted 12 lines · Mateusz Polchlopek
Quoted 9 lines · Heiner Kallweit

Certain fixup-related definitions aren't used outside phy_device.c. So make them private and remove them from phy.h.

---
  drivers/net/phy/phy_device.c | 16 +++++++++++++--- include/linux/phy.h          | 14 --------------

  2 files changed, 13 insertions(+), 17 deletions(-)
Quoted 14 lines

drivers/net/phy/phy_device.c

Quoted 10 lines
drivers/net/phy/phy_device.c +0 -0
index 9b06ba92f..14c312ad2 100644
@@ -45,6 +45,17 @@ MODULE_DESCRIPTION("PHY library");
   MODULE_AUTHOR("Andy Fleming");
   MODULE_LICENSE("GPL");

  +#define    PHY_ANY_ID    "MATCH ANY PHY"

drivers/net/phy/phy_device.c +2 -0
+#define    PHY_ANY_UID    0xffffffff
+

Overall looks like a nice cleanup but I am not sure about this space between #define and PHY_ANY_ID or PHY_ANY_UID...

There's a tab, which effectively equals a space. Maybe it's just the diff which is misleading. At least checkpatch didn't complain.

Quoted 63 lines
Quoted 62 lines
drivers/net/phy/phy_device.c +8 -0
+struct phy_fixup {
+    struct list_head list;
+    char bus_id[MII_BUS_ID_SIZE + 3];
+    u32 phy_uid;
+    u32 phy_uid_mask;
+    int (*run)(struct phy_device *phydev);
+};
+

  __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_features) __ro_after_init; EXPORT_SYMBOL_GPL(phy_basic_features);
  @@ -378,8 +389,8 @@ static SIMPLE_DEV_PM_OPS(mdio_bus_phy_pm_ops, mdio_bus_phy_suspend, *    comparison
   * @run: The actual code to be run when a matching PHY is found
   */

drivers/net/phy/phy_device.c +2 -2
-int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-               int (*run)(struct phy_device *))
+static int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+                  int (*run)(struct phy_device *))

  {
      struct phy_fixup *fixup = kzalloc(sizeof(*fixup), GFP_KERNEL);
  @@ -397,7 +408,6 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, return 0;
  }
-EXPORT_SYMBOL(phy_register_fixup);
    /* Registers a fixup to be run on any PHY with the UID in phy_uid */
  int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,

include/linux/phy.h +0 -0
index 29df4c602..96e427c2c 100644
@@ -1277,9 +1277,6 @@ struct phy_driver {
   #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d),        \
                         struct phy_driver, mdiodrv)

  -#define PHY_ANY_ID "MATCH ANY PHY"

include/linux/phy.h +0 -2
-#define PHY_ANY_UID 0xffffffff
-

  #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0) #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4) #define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10)

include/linux/phy.h +0 -0
@@ -1312,15 +1309,6 @@ static inline bool phydev_id_compare(struct phy_device *phydev, u32 id)
       return phy_id_compare(id, phydev->phy_id, phydev->drv->phy_id_mask);
   }

  -/* A Structure for boards to register fixups with the PHY Lib */

include/linux/phy.h +0 -8
-struct phy_fixup {
-    struct list_head list;
-    char bus_id[MII_BUS_ID_SIZE + 3];
-    u32 phy_uid;
-    u32 phy_uid_mask;
-    int (*run)(struct phy_device *phydev);
-};
-

  const char *phy_speed_to_str(int speed);
  const char *phy_duplex_to_str(unsigned int duplex); const char *phy_rate_matching_to_str(int rate_matching);

include/linux/phy.h +0 -1
@@ -2117,8 +2105,6 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
   void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv,
                  bool *tx_pause, bool *rx_pause);
   -int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
-               int (*run)(struct phy_device *));
   int phy_register_fixup_for_id(const char *bus_id,
                     int (*run)(struct phy_device *));
   int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
reviewer Reviewed-by on v1 1/4
#5 lore raw

Re: [PATCH net-next 1/4] net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

In reply to Heiner Kallweit
Quoted 4 lines · Heiner Kallweit

Certain fixup-related definitions aren't used outside phy_device.c. So make them private and remove them from phy.h.

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
reviewer Reviewed-by on v1 2/4
#8 lore raw

Re: [PATCH net-next 2/4] net: phy: stop exporting feature arrays which aren't used outside phylib

In reply to Heiner Kallweit
Quoted 3 lines · Heiner Kallweit

Stop exporting feature arrays which aren't used outside phylib.

My grep confirms.

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
reviewer Reviewed-by on v1 3/4
#11 lore raw

Re: [PATCH net-next 3/4] net: phy: stop exporting phy_queue_state_machine

In reply to Heiner Kallweit
Quoted 4 lines · Heiner Kallweit

phy_queue_state_machine() isn't used outside phy.c, so stop exporting it.

My grep confirms.

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
reviewer Reviewed-by on v1 4/4
#14 lore raw

Re: [PATCH net-next 4/4] net: phy: remove helper phy_is_internal

In reply to Heiner Kallweit
Quoted 4 lines · Heiner Kallweit

Helper phy_is_internal() is just used in two places phylib-internally. So let's remove it from the API.

My grep confirms.

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
maintainer Reviewed-by
#4 lore raw

Re: [PATCH net-next 1/4] net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

In reply to Heiner Kallweit
Quoted 27 lines · Heiner Kallweit
Quoted 12 lines · Mateusz Polchlopek
Quoted 9 lines · Heiner Kallweit

Certain fixup-related definitions aren't used outside phy_device.c. So make them private and remove them from phy.h.

---
  drivers/net/phy/phy_device.c | 16 +++++++++++++--- include/linux/phy.h          | 14 --------------

  2 files changed, 13 insertions(+), 17 deletions(-)
Quoted 14 lines

drivers/net/phy/phy_device.c

Quoted 10 lines
drivers/net/phy/phy_device.c +0 -0
index 9b06ba92f..14c312ad2 100644
@@ -45,6 +45,17 @@ MODULE_DESCRIPTION("PHY library");
   MODULE_AUTHOR("Andy Fleming");
   MODULE_LICENSE("GPL");

  +#define    PHY_ANY_ID    "MATCH ANY PHY"

drivers/net/phy/phy_device.c +2 -0
+#define    PHY_ANY_UID    0xffffffff
+

Overall looks like a nice cleanup but I am not sure about this space between #define and PHY_ANY_ID or PHY_ANY_UID...

Quoted 2 lines

There's a tab, which effectively equals a space. Maybe it's just the diff which is misleading. At least checkpatch didn't complain.

So long as it is a straight cut/paste from the old location, this is fine.

Andrew

#15 lore raw
In reply to Heiner Kallweit
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Thu, 13 Feb 2025 22:47:04 +0100 you wrote:

This series is a starting point to clean up phy.h and remove definitions which are phylib-internal.

Heiner Kallweit (4):
net: phy: remove fixup-related definitions from phy.h which are not
used outside phylib
net: phy: stop exporting feature arrays which aren't used outside
phylib
net: phy: stop exporting phy_queue_state_machine
net: phy: remove helper phy_is_internal

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/4] net: phy: remove fixup-related definitions from phy.h which are not used outside phylib

    https://git.kernel.org/netdev/net-next/c/ea47e70e476f
  - [net-next,2/4] net: phy: stop exporting feature arrays which aren't used outside phylib
    https://git.kernel.org/netdev/net-next/c/d3a0e217f850
  - [net-next,3/4] net: phy: stop exporting phy_queue_state_machine
    https://git.kernel.org/netdev/net-next/c/ef6249e37df5
  - [net-next,4/4] net: phy: remove helper phy_is_internal
    https://git.kernel.org/netdev/net-next/c/6b2edfba7469

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html