diff mbox series

[net-next,09/10] net: dsa: bcm_sf2: stop assigning an OF node to the ds->user_mii_bus

Message ID 20240104140037.374166-10-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 04a4bc9dddc7bd316ba555338c04b885581be5ae
Delegated to: Netdev Maintainers
Headers show
Series ds->user_mii_bus cleanup (part 1) | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean Jan. 4, 2024, 2 p.m. UTC
The bcm_sf2 driver does something strange. Instead of calling
of_mdiobus_register() with an OF node argument, it manually assigns the
bus->dev->of_node and then calls the non-OF mdiobus_register(). This
circumvents some code from __of_mdiobus_register() from running, which
sets the auto-scan mask, parses some device tree properties, etc.

I'm going to go out on a limb and say that the OF node isn't, in fact,
needed at all, and can be removed. The MDIO diversion as initially
implemented in commit 461cd1b03e32 ("net: dsa: bcm_sf2: Register our
slave MDIO bus") looked quite different than it is now, after commit
771089c2a485 ("net: dsa: bcm_sf2: Ensure that MDIO diversion is used").
Initially, it made sense, as bcm_sf2 was registering another set of
driver ops for the "brcm,unimac-mdio" OF node. But now, it deletes all
phandles, which makes "phy-handle"s unable to find PHYs, which means
that it always goes through the OF-unaware dsa_user_phy_connect().

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/bcm_sf2.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Alvin Šipraga Jan. 4, 2024, 3:59 p.m. UTC | #1
On Thu, Jan 04, 2024 at 04:00:36PM +0200, Vladimir Oltean wrote:
> The bcm_sf2 driver does something strange. Instead of calling
> of_mdiobus_register() with an OF node argument, it manually assigns the
> bus->dev->of_node and then calls the non-OF mdiobus_register(). This
> circumvents some code from __of_mdiobus_register() from running, which
> sets the auto-scan mask, parses some device tree properties, etc.
> 
> I'm going to go out on a limb and say that the OF node isn't, in fact,
> needed at all, and can be removed. The MDIO diversion as initially
> implemented in commit 461cd1b03e32 ("net: dsa: bcm_sf2: Register our
> slave MDIO bus") looked quite different than it is now, after commit
> 771089c2a485 ("net: dsa: bcm_sf2: Ensure that MDIO diversion is used").
> Initially, it made sense, as bcm_sf2 was registering another set of
> driver ops for the "brcm,unimac-mdio" OF node. But now, it deletes all
> phandles, which makes "phy-handle"s unable to find PHYs, which means
> that it always goes through the OF-unaware dsa_user_phy_connect().
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>

> ---
>  drivers/net/dsa/bcm_sf2.c | 1 -
>  1 file changed, 1 deletion(-)
Florian Fainelli Jan. 4, 2024, 5:32 p.m. UTC | #2
On 1/4/24 06:00, Vladimir Oltean wrote:
> The bcm_sf2 driver does something strange. Instead of calling
> of_mdiobus_register() with an OF node argument, it manually assigns the
> bus->dev->of_node and then calls the non-OF mdiobus_register(). This
> circumvents some code from __of_mdiobus_register() from running, which
> sets the auto-scan mask, parses some device tree properties, etc.
> 
> I'm going to go out on a limb and say that the OF node isn't, in fact,
> needed at all, and can be removed. The MDIO diversion as initially
> implemented in commit 461cd1b03e32 ("net: dsa: bcm_sf2: Register our
> slave MDIO bus") looked quite different than it is now, after commit
> 771089c2a485 ("net: dsa: bcm_sf2: Ensure that MDIO diversion is used").
> Initially, it made sense, as bcm_sf2 was registering another set of
> driver ops for the "brcm,unimac-mdio" OF node. But now, it deletes all
> phandles, which makes "phy-handle"s unable to find PHYs, which means
> that it always goes through the OF-unaware dsa_user_phy_connect().
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index cadee5505c29..19b325fa5a27 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -635,7 +635,6 @@  static int bcm_sf2_mdio_register(struct dsa_switch *ds)
 	priv->user_mii_bus->write = bcm_sf2_sw_mdio_write;
 	snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "sf2-%d",
 		 index++);
-	priv->user_mii_bus->dev.of_node = dn;
 
 	/* Include the pseudo-PHY address to divert reads towards our
 	 * workaround. This is only required for 7445D0, since 7445E0