[PATCH 10/20] net: phy: Simplify the logic of phy_connect_fixed()

Ramon Fried rfried.dev at gmail.com
Tue Mar 2 18:46:11 CET 2021


On Tue, Mar 2, 2021 at 5:36 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Simplify the logic of phy_connect_fixed() by using the new API
> ofnode_phy_is_fixed_link(), which brings additional bonus of
> supporting the old DT bindings.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
>  drivers/net/phy/phy.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 69e02685fa..0e85a80761 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -18,6 +18,7 @@
>  #include <phy.h>
>  #include <errno.h>
>  #include <asm/global_data.h>
> +#include <dm/of_extra.h>
>  #include <linux/bitops.h>
>  #include <linux/delay.h>
>  #include <linux/err.h>
> @@ -1002,19 +1003,12 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
>                                             phy_interface_t interface)
>  {
>         struct phy_device *phydev = NULL;
> -       ofnode node = dev_ofnode(dev);
> -       const char *name;
> +       ofnode eth_node = dev_ofnode(dev);
> +       ofnode phy_node;
>
> -       node = ofnode_first_subnode(node);
> -       while (ofnode_valid(node)) {
> -               name = ofnode_get_name(node);
> -               if (name && strcmp(name, "fixed-link") == 0) {
> -                       phydev = phy_device_create(bus, ofnode_to_offset(node),
> -                                                  PHY_FIXED_ID, false,
> -                                                  interface);
> -                       break;
> -               }
> -               node = ofnode_next_subnode(node);
> +       if (ofnode_phy_is_fixed_link(eth_node, &phy_node)) {
> +               phydev = phy_device_create(bus, ofnode_to_offset(phy_node),
> +                                          PHY_FIXED_ID, false, interface);
>         }
>
>         return phydev;
> --
> 2.25.1
>
Reviewed-By: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list