Re: [PATCH net-next] driver: cadence macb driver support acpi mode

From: Andrew Lunn
Date: Wed Aug 24 2022 - 11:26:18 EST


> +static int macb_acpi_phylink_connect(struct macb *bp)
> +{
> + struct fwnode_handle *fwnd = bp->pdev->dev.fwnode;
> + struct net_device *dev = bp->dev;
> + struct phy_device *phydev;
> + int ret;
> +
> + if (fwnd)
> + ret = phylink_fwnode_phy_connect(bp->phylink, fwnd, 0);
> +
> + if (!fwnd || (ret && !macb_acpi_phy_handle_exists(fwnd))) {
> + phydev = phy_find_first(bp->mii_bus);

Please don't use phy_find_first. That is somewhat historical. Since
this is a new binding, simply error out if
phylink_fwnode_phy_connect() fails.

> +static int macb_acpi_mdiobus_register(struct macb *bp)
> +{
> + struct platform_device *pdev = bp->pdev;
> + struct fwnode_handle *fwnode = pdev->dev.fwnode;
> + struct fwnode_handle *child;
> + u32 addr;
> + int ret;
> +
> + if (!IS_ERR_OR_NULL(fwnode_find_reference(pdev->dev.fwnode, "fixed-link", 0)))
> + return mdiobus_register(bp->mii_bus);
> +
> + fwnode_for_each_child_node(fwnode, child) {
> + ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> + if (ret || addr >= PHY_MAX_ADDR)
> + continue;
> + ret = acpi_mdiobus_register(bp->mii_bus, fwnode);
> + if (!ret)
> + return ret;
> + break;

Why loop looking for a node with a register value < 32?

Please make sure you are conformant with Documentation/firmware-guide/acpi/dsd/phy.rst

Andrew