[PATCH 02/20] net: phy: xilinx: Convert to use APIs which support live DT

Ramon Fried rfried.dev at gmail.com
Tue Mar 2 18:51:26 CET 2021


On Tue, Mar 2, 2021 at 5:35 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Use ofnode_ APIs instead of fdt_ APIs so that the Xilinx PHY driver
> can support live DT.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
>  drivers/net/phy/phy.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index d9e03baf7b..f0522fc149 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -947,23 +947,18 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
>                                                  phy_interface_t interface)
>  {
>         struct phy_device *phydev = NULL;
> -       int sn = dev_of_offset(dev);
> -       int off;
> +       ofnode node = dev_ofnode(dev);
>
> -       while (sn > 0) {
> -               off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
> -                                                   "xlnx,gmii-to-rgmii-1.0");
> -               if (off > 0) {
> -                       phydev = phy_device_create(bus, off,
> +       while (ofnode_valid(node)) {
> +               node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0");
> +               if (ofnode_valid(node)) {
> +                       phydev = phy_device_create(bus, ofnode_to_offset(node),
>                                                    PHY_GMII2RGMII_ID, false,
>                                                    interface);
>                         break;
>                 }
> -               if (off == -FDT_ERR_NOTFOUND)
> -                       sn = fdt_first_subnode(gd->fdt_blob, sn);
> -               else
> -                       printf("%s: Error finding compat string:%d\n",
> -                              __func__, off);
> +
> +               node = ofnode_first_subnode(node);
>         }
>
>         return phydev;
> --
> 2.25.1
>
Reviewed-By: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list