* [PATCH net-next 1/4] net: phy: add iterator phy_for_each
2025-10-17 20:39 [PATCH net-next 0/4] net: phy: add iterator phy_for_each Heiner Kallweit
@ 2025-10-17 20:41 ` Heiner Kallweit
2025-10-17 20:51 ` Gerhard Engleder
2025-10-22 1:24 ` Jakub Kicinski
2025-10-17 20:41 ` [PATCH net-next 2/4] net: fec: use new " Heiner Kallweit
` (3 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Heiner Kallweit @ 2025-10-17 20:41 UTC (permalink / raw)
To: Wei Fang, Shenwei Wang, Clark Wang, Siddharth Vadapalli,
Roger Quadros
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller
Add an iterator for all PHY's on a MII bus, and phy_find_next()
as a prerequisite.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 14 +++++++-------
include/linux/phy.h | 11 ++++++++++-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7a67c900e..72d58b38d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1214,22 +1214,22 @@ int phy_get_c45_ids(struct phy_device *phydev)
EXPORT_SYMBOL(phy_get_c45_ids);
/**
- * phy_find_first - finds the first PHY device on the bus
+ * phy_find_next - finds the next PHY device on the bus
* @bus: the target MII bus
+ * @pos: cursor
*/
-struct phy_device *phy_find_first(struct mii_bus *bus)
+struct phy_device *phy_find_next(struct mii_bus *bus, struct phy_device *pos)
{
- struct phy_device *phydev;
- int addr;
+ for (int addr = pos ? pos->mdio.addr + 1 : 0;
+ addr < PHY_MAX_ADDR; addr++) {
+ struct phy_device *phydev = mdiobus_get_phy(bus, addr);
- for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
- phydev = mdiobus_get_phy(bus, addr);
if (phydev)
return phydev;
}
return NULL;
}
-EXPORT_SYMBOL(phy_find_first);
+EXPORT_SYMBOL_GPL(phy_find_next);
/**
* phy_prepare_link - prepares the PHY layer to monitor link status
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3c7634482..b0497f47b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1848,7 +1848,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,
@@ -1875,6 +1875,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 phy_for_each(_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);
--
2.51.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net-next 1/4] net: phy: add iterator phy_for_each
2025-10-17 20:41 ` [PATCH net-next 1/4] " Heiner Kallweit
@ 2025-10-17 20:51 ` Gerhard Engleder
2025-10-22 1:24 ` Jakub Kicinski
1 sibling, 0 replies; 12+ messages in thread
From: Gerhard Engleder @ 2025-10-17 20:51 UTC (permalink / raw)
To: Heiner Kallweit
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Wei Fang, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros
On 17.10.25 22:41, Heiner Kallweit wrote:
> Add an iterator for all PHY's on a MII bus, and phy_find_next()
> as a prerequisite.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/phy/phy_device.c | 14 +++++++-------
> include/linux/phy.h | 11 ++++++++++-
> 2 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 7a67c900e..72d58b38d 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1214,22 +1214,22 @@ int phy_get_c45_ids(struct phy_device *phydev)
> EXPORT_SYMBOL(phy_get_c45_ids);
>
> /**
> - * phy_find_first - finds the first PHY device on the bus
> + * phy_find_next - finds the next PHY device on the bus
> * @bus: the target MII bus
> + * @pos: cursor
> */
> -struct phy_device *phy_find_first(struct mii_bus *bus)
> +struct phy_device *phy_find_next(struct mii_bus *bus, struct phy_device *pos)
> {
> - struct phy_device *phydev;
> - int addr;
> + for (int addr = pos ? pos->mdio.addr + 1 : 0;
> + addr < PHY_MAX_ADDR; addr++) {
> + struct phy_device *phydev = mdiobus_get_phy(bus, addr);
>
> - for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
> - phydev = mdiobus_get_phy(bus, addr);
> if (phydev)
> return phydev;
> }
> return NULL;
> }
> -EXPORT_SYMBOL(phy_find_first);
> +EXPORT_SYMBOL_GPL(phy_find_next);
>
> /**
> * phy_prepare_link - prepares the PHY layer to monitor link status
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 3c7634482..b0497f47b 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1848,7 +1848,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,
> @@ -1875,6 +1875,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 phy_for_each(_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);
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH net-next 1/4] net: phy: add iterator phy_for_each
2025-10-17 20:41 ` [PATCH net-next 1/4] " Heiner Kallweit
2025-10-17 20:51 ` Gerhard Engleder
@ 2025-10-22 1:24 ` Jakub Kicinski
2025-10-22 2:00 ` Andrew Lunn
1 sibling, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2025-10-22 1:24 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Wei Fang, Shenwei Wang, Clark Wang, Siddharth Vadapalli,
Roger Quadros, netdev@vger.kernel.org, imx, linux-omap,
Andrew Lunn, Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Eric Dumazet, David Miller
On Fri, 17 Oct 2025 22:41:12 +0200 Heiner Kallweit wrote:
> +#define phy_for_each(_bus, _phydev) \
> + for (_phydev = phy_find_first(_bus); _phydev; \
> + _phydev = phy_find_next(_bus, _phydev))
Wouldn't this better be called mii_for_each_phy() or
mii_bus_for_each_phy() ?
To an outsider and with PHY typologies it may not be
sufficiently obvious that this helper is used to iterate
a all addresses on a MII bus.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/4] net: phy: add iterator phy_for_each
2025-10-22 1:24 ` Jakub Kicinski
@ 2025-10-22 2:00 ` Andrew Lunn
0 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2025-10-22 2:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Heiner Kallweit, Wei Fang, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros, netdev@vger.kernel.org, imx,
linux-omap, Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Eric Dumazet, David Miller
On Tue, Oct 21, 2025 at 06:24:51PM -0700, Jakub Kicinski wrote:
> On Fri, 17 Oct 2025 22:41:12 +0200 Heiner Kallweit wrote:
> > +#define phy_for_each(_bus, _phydev) \
> > + for (_phydev = phy_find_first(_bus); _phydev; \
> > + _phydev = phy_find_next(_bus, _phydev))
>
> Wouldn't this better be called mii_for_each_phy() or
> mii_bus_for_each_phy() ?
>
> To an outsider and with PHY typologies it may not be
> sufficiently obvious that this helper is used to iterate
> a all addresses on a MII bus.
The naming scheme suggest it either needs to start with phy_ or
mdiobus_.
mdiobus_for_each_phy() might be the best name, if you want to indicate
it iterates an mdio bus. It should also be noted that it will ignore
devices on the bus which are not PHYs. So we need phy in the name
somewhere.
Andrew
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 2/4] net: fec: use new iterator phy_for_each
2025-10-17 20:39 [PATCH net-next 0/4] net: phy: add iterator phy_for_each Heiner Kallweit
2025-10-17 20:41 ` [PATCH net-next 1/4] " Heiner Kallweit
@ 2025-10-17 20:41 ` Heiner Kallweit
2025-10-17 20:51 ` Gerhard Engleder
2025-10-17 20:42 ` [PATCH net-next 3/4] net: davinci_mdio: " Heiner Kallweit
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2025-10-17 20:41 UTC (permalink / raw)
To: Wei Fang, Shenwei Wang, Clark Wang, Siddharth Vadapalli,
Roger Quadros
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller
Use new iterator phy_for_each() to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/freescale/fec_main.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 1edcfaee6..d7c39ef2d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2552,7 +2552,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
int err = -ENXIO;
u32 mii_speed, holdtime;
u32 bus_freq;
- int addr;
/*
* The i.MX28 dual fec interfaces are not equal.
@@ -2667,11 +2666,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
of_node_put(node);
/* find all the PHY devices on the bus and set mac_managed_pm to true */
- for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
- phydev = mdiobus_get_phy(fep->mii_bus, addr);
- if (phydev)
- phydev->mac_managed_pm = true;
- }
+ phy_for_each(fep->mii_bus, phydev)
+ phydev->mac_managed_pm = true;
mii_cnt++;
--
2.51.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net-next 2/4] net: fec: use new iterator phy_for_each
2025-10-17 20:41 ` [PATCH net-next 2/4] net: fec: use new " Heiner Kallweit
@ 2025-10-17 20:51 ` Gerhard Engleder
0 siblings, 0 replies; 12+ messages in thread
From: Gerhard Engleder @ 2025-10-17 20:51 UTC (permalink / raw)
To: Heiner Kallweit
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Wei Fang, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros
On 17.10.25 22:41, Heiner Kallweit wrote:
> Use new iterator phy_for_each() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 1edcfaee6..d7c39ef2d 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -2552,7 +2552,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
> int err = -ENXIO;
> u32 mii_speed, holdtime;
> u32 bus_freq;
> - int addr;
>
> /*
> * The i.MX28 dual fec interfaces are not equal.
> @@ -2667,11 +2666,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
> of_node_put(node);
>
> /* find all the PHY devices on the bus and set mac_managed_pm to true */
> - for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
> - phydev = mdiobus_get_phy(fep->mii_bus, addr);
> - if (phydev)
> - phydev->mac_managed_pm = true;
> - }
> + phy_for_each(fep->mii_bus, phydev)
> + phydev->mac_managed_pm = true;
>
> mii_cnt++;
>
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 3/4] net: davinci_mdio: use new iterator phy_for_each
2025-10-17 20:39 [PATCH net-next 0/4] net: phy: add iterator phy_for_each Heiner Kallweit
2025-10-17 20:41 ` [PATCH net-next 1/4] " Heiner Kallweit
2025-10-17 20:41 ` [PATCH net-next 2/4] net: fec: use new " Heiner Kallweit
@ 2025-10-17 20:42 ` Heiner Kallweit
2025-10-17 20:51 ` Gerhard Engleder
2025-10-17 20:43 ` [PATCH net-next 4/4] net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan Heiner Kallweit
2025-10-20 2:44 ` [PATCH net-next 0/4] net: phy: add iterator phy_for_each Wei Fang
4 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2025-10-17 20:42 UTC (permalink / raw)
To: Wei Fang, Shenwei Wang, Clark Wang, Siddharth Vadapalli,
Roger Quadros
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller
Use new iterator phy_for_each() to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/ti/davinci_mdio.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 68507126b..5a7ed5ebf 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -548,8 +548,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
struct davinci_mdio_data *data;
struct resource *res;
struct phy_device *phy;
- int ret, addr;
int autosuspend_delay_ms = -1;
+ int ret;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -652,14 +652,10 @@ static int davinci_mdio_probe(struct platform_device *pdev)
goto bail_out;
/* scan and dump the bus */
- for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
- phy = mdiobus_get_phy(data->bus, addr);
- if (phy) {
- dev_info(dev, "phy[%d]: device %s, driver %s\n",
- phy->mdio.addr, phydev_name(phy),
- phy->drv ? phy->drv->name : "unknown");
- }
- }
+ phy_for_each(data->bus, phy)
+ dev_info(dev, "phy[%d]: device %s, driver %s\n",
+ phy->mdio.addr, phydev_name(phy),
+ phy->drv ? phy->drv->name : "unknown");
return 0;
--
2.51.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net-next 3/4] net: davinci_mdio: use new iterator phy_for_each
2025-10-17 20:42 ` [PATCH net-next 3/4] net: davinci_mdio: " Heiner Kallweit
@ 2025-10-17 20:51 ` Gerhard Engleder
0 siblings, 0 replies; 12+ messages in thread
From: Gerhard Engleder @ 2025-10-17 20:51 UTC (permalink / raw)
To: Heiner Kallweit
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Wei Fang, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros
On 17.10.25 22:42, Heiner Kallweit wrote:
> Use new iterator phy_for_each() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/ethernet/ti/davinci_mdio.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index 68507126b..5a7ed5ebf 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -548,8 +548,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
> struct davinci_mdio_data *data;
> struct resource *res;
> struct phy_device *phy;
> - int ret, addr;
> int autosuspend_delay_ms = -1;
> + int ret;
>
> data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> @@ -652,14 +652,10 @@ static int davinci_mdio_probe(struct platform_device *pdev)
> goto bail_out;
>
> /* scan and dump the bus */
> - for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
> - phy = mdiobus_get_phy(data->bus, addr);
> - if (phy) {
> - dev_info(dev, "phy[%d]: device %s, driver %s\n",
> - phy->mdio.addr, phydev_name(phy),
> - phy->drv ? phy->drv->name : "unknown");
> - }
> - }
> + phy_for_each(data->bus, phy)
> + dev_info(dev, "phy[%d]: device %s, driver %s\n",
> + phy->mdio.addr, phydev_name(phy),
> + phy->drv ? phy->drv->name : "unknown");
>
> return 0;
>
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 4/4] net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan
2025-10-17 20:39 [PATCH net-next 0/4] net: phy: add iterator phy_for_each Heiner Kallweit
` (2 preceding siblings ...)
2025-10-17 20:42 ` [PATCH net-next 3/4] net: davinci_mdio: " Heiner Kallweit
@ 2025-10-17 20:43 ` Heiner Kallweit
2025-10-17 20:52 ` Gerhard Engleder
2025-10-20 2:44 ` [PATCH net-next 0/4] net: phy: add iterator phy_for_each Wei Fang
4 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2025-10-17 20:43 UTC (permalink / raw)
To: Wei Fang, Shenwei Wang, Clark Wang, Siddharth Vadapalli,
Roger Quadros
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller
Use new iterator phy_for_each() to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/mdio_bus_provider.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/phy/mdio_bus_provider.c b/drivers/net/phy/mdio_bus_provider.c
index a2391d4b7..20792480d 100644
--- a/drivers/net/phy/mdio_bus_provider.c
+++ b/drivers/net/phy/mdio_bus_provider.c
@@ -249,20 +249,15 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus)
*/
static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)
{
- int i;
+ struct phy_device *phydev;
- for (i = 0; i < PHY_MAX_ADDR; i++) {
- struct phy_device *phydev;
- u32 oui;
-
- phydev = mdiobus_get_phy(bus, i);
- if (!phydev)
- continue;
- oui = phydev->phy_id >> 10;
+ phy_for_each(bus, phydev) {
+ u32 oui = phydev->phy_id >> 10;
if (oui == MICREL_OUI)
return true;
}
+
return false;
}
--
2.51.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net-next 4/4] net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan
2025-10-17 20:43 ` [PATCH net-next 4/4] net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan Heiner Kallweit
@ 2025-10-17 20:52 ` Gerhard Engleder
0 siblings, 0 replies; 12+ messages in thread
From: Gerhard Engleder @ 2025-10-17 20:52 UTC (permalink / raw)
To: Heiner Kallweit
Cc: netdev@vger.kernel.org, imx, linux-omap, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Wei Fang, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros
On 17.10.25 22:43, Heiner Kallweit wrote:
> Use new iterator phy_for_each() to simplify the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/phy/mdio_bus_provider.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/phy/mdio_bus_provider.c b/drivers/net/phy/mdio_bus_provider.c
> index a2391d4b7..20792480d 100644
> --- a/drivers/net/phy/mdio_bus_provider.c
> +++ b/drivers/net/phy/mdio_bus_provider.c
> @@ -249,20 +249,15 @@ static int mdiobus_scan_bus_c45(struct mii_bus *bus)
> */
> static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)
> {
> - int i;
> + struct phy_device *phydev;
>
> - for (i = 0; i < PHY_MAX_ADDR; i++) {
> - struct phy_device *phydev;
> - u32 oui;
> -
> - phydev = mdiobus_get_phy(bus, i);
> - if (!phydev)
> - continue;
> - oui = phydev->phy_id >> 10;
> + phy_for_each(bus, phydev) {
> + u32 oui = phydev->phy_id >> 10;
>
> if (oui == MICREL_OUI)
> return true;
> }
> +
> return false;
> }
>
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH net-next 0/4] net: phy: add iterator phy_for_each
2025-10-17 20:39 [PATCH net-next 0/4] net: phy: add iterator phy_for_each Heiner Kallweit
` (3 preceding siblings ...)
2025-10-17 20:43 ` [PATCH net-next 4/4] net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan Heiner Kallweit
@ 2025-10-20 2:44 ` Wei Fang
4 siblings, 0 replies; 12+ messages in thread
From: Wei Fang @ 2025-10-20 2:44 UTC (permalink / raw)
To: Heiner Kallweit
Cc: netdev@vger.kernel.org, imx@lists.linux.dev,
linux-omap@vger.kernel.org, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, Shenwei Wang, Clark Wang,
Siddharth Vadapalli, Roger Quadros
> Add and use an iterator for all PHY's on a MII bus, and phy_find_next() as a
> prerequisite.
>
> Heiner Kallweit (4):
> net: phy: add iterator phy_for_each
> net: fec: use new iterator phy_for_each
> net: davinci_mdio: use new iterator phy_for_each
> net: phy: use new iterator phy_for_each in mdiobus_prevent_c45_scan
>
> drivers/net/ethernet/freescale/fec_main.c | 8 ++------
> drivers/net/ethernet/ti/davinci_mdio.c | 14 +++++---------
> drivers/net/phy/mdio_bus_provider.c | 13 ++++---------
> drivers/net/phy/phy_device.c | 14 +++++++-------
> include/linux/phy.h | 11 ++++++++++-
> 5 files changed, 28 insertions(+), 32 deletions(-)
>
> --
> 2.51.1.dirty
For this patch set.
Reviewed-by: Wei Fang <wei.fang@nxp.com>
^ permalink raw reply [flat|nested] 12+ messages in thread