diff mbox series

[net-next,2/2] net: macb: Use mdio child node for MDIO bus if it exists

Message ID 20211022163548.3380625-2-sean.anderson@seco.com (mailing list archive)
State Accepted
Commit 4d98bb0d7ec2d0b417df6207b0bafe1868bad9f8
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] dt-bindings: net: macb: Add mdio bus child node | expand

Checks

Context Check Description
netdev/cover_letter success Single patches do not need cover letters
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 25 this patch: 25
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 25 this patch: 25
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Sean Anderson Oct. 22, 2021, 4:35 p.m. UTC
This allows explicitly specifying which children are present on the mdio
bus. Additionally, it allows for non-phy MDIO devices on the bus.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 drivers/net/ethernet/cadence/macb_main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Andrew Lunn Oct. 22, 2021, 7:43 p.m. UTC | #1
On Fri, Oct 22, 2021 at 12:35:48PM -0400, Sean Anderson wrote:
> This allows explicitly specifying which children are present on the mdio
> bus. Additionally, it allows for non-phy MDIO devices on the bus.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Guenter Roeck Oct. 26, 2021, 4:49 p.m. UTC | #2
Hi,

while bisecting I noticed the following.

On Fri, Oct 22, 2021 at 12:35:48PM -0400, Sean Anderson wrote:
> This allows explicitly specifying which children are present on the mdio
> bus. Additionally, it allows for non-phy MDIO devices on the bus.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
> 
>  drivers/net/ethernet/cadence/macb_main.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 029dea2873e3..30a65cac9e87 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -898,6 +898,17 @@ static int macb_mdiobus_register(struct macb *bp)
>  {
>  	struct device_node *child, *np = bp->pdev->dev.of_node;
>  
> +	/* If we have a child named mdio, probe it instead of looking for PHYs
> +	 * directly under the MAC node
> +	 */
> +	child = of_get_child_by_name(np, "mdio");
> +	if (np) {

s/np/child/ 

to avoid network interface failures with messages like

[   12.764530] macb 10090000.ethernet eth0: Could not attach PHY (-19)

I'll send a patch in a minute to fix this up, after bisect is complete
and after testing, to make sure that there is no additional problem.

Guenter

> +		int ret = of_mdiobus_register(bp->mii_bus, child);
> +
> +		of_node_put(child);
> +		return ret;
> +	}
> +
>  	if (of_phy_is_fixed_link(np))
>  		return mdiobus_register(bp->mii_bus);
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 029dea2873e3..30a65cac9e87 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -898,6 +898,17 @@  static int macb_mdiobus_register(struct macb *bp)
 {
 	struct device_node *child, *np = bp->pdev->dev.of_node;
 
+	/* If we have a child named mdio, probe it instead of looking for PHYs
+	 * directly under the MAC node
+	 */
+	child = of_get_child_by_name(np, "mdio");
+	if (np) {
+		int ret = of_mdiobus_register(bp->mii_bus, child);
+
+		of_node_put(child);
+		return ret;
+	}
+
 	if (of_phy_is_fixed_link(np))
 		return mdiobus_register(bp->mii_bus);