[PATCH net-next] driver: cadence macb driver support acpi mode
Andrew Lunn
andrew at lunn.ch
Wed Aug 24 08:25:55 PDT 2022
> +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
More information about the linux-riscv
mailing list