summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-10-30 05:00:37 +0300
committerJakub Kicinski <kuba@kernel.org>2025-10-30 05:00:37 +0300
commit1bae0fd90077875b6c9c853245189032cbf019f7 (patch)
treea18c894fe552f8528d4a931602d3f89ae26be1d7 /include/linux
parentcf35f4347ddd42ceca156e57a87ec489788f1bd7 (diff)
parentd4780abb8cce3692f24ea2f1cf162092075e91e8 (diff)
downloadlinux-1bae0fd90077875b6c9c853245189032cbf019f7.tar.xz
Merge branch 'net-phy-add-iterator-mdiobus_for_each_phy'
Heiner Kallweit says: ==================== net: phy: add iterator mdiobus_for_each_phy Add and use an iterator for all PHY's on a MII bus, and phy_find_next() as a prerequisite. ==================== Link: https://patch.msgid.link/07fc63e8-53fd-46aa-853e-96187bba9d44@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/phy.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 17a2cdc9f1a0..358dd6f0ff96 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1869,7 +1869,7 @@ 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);
+struct phy_device *phy_find_next(struct mii_bus *bus, struct phy_device *pos);
int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
u32 flags, phy_interface_t interface);
int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
@@ -1896,6 +1896,15 @@ bool phy_check_valid(int speed, int duplex, unsigned long *features);
int phy_restart_aneg(struct phy_device *phydev);
int phy_reset_after_clk_enable(struct phy_device *phydev);
+static inline struct phy_device *phy_find_first(struct mii_bus *bus)
+{
+ return phy_find_next(bus, NULL);
+}
+
+#define mdiobus_for_each_phy(_bus, _phydev) \
+ for (_phydev = phy_find_first(_bus); _phydev; \
+ _phydev = phy_find_next(_bus, _phydev))
+
#if IS_ENABLED(CONFIG_PHYLIB)
int phy_start_cable_test(struct phy_device *phydev,
struct netlink_ext_ack *extack);