diff mbox series

net: phy: micrel: Get phy node from phy-handle

Message ID 20210426034347.2669-1-ley.foon.tan@intel.com
State Accepted
Delegated to: Ramon Fried
Headers show
Series net: phy: micrel: Get phy node from phy-handle | expand

Commit Message

Ley Foon Tan April 26, 2021, 3:43 a.m. UTC
If can't find ethernet-phy subnode, try to get phy node from "phy-handle".
Lastly, only use Ethernet node if can't find phy node from ethernet-phy
subnode and phy-handle.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 drivers/net/phy/micrel_ksz90x1.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Ramon Fried April 29, 2021, 8:26 p.m. UTC | #1
On Mon, Apr 26, 2021 at 6:43 AM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
>
> If can't find ethernet-phy subnode, try to get phy node from "phy-handle".
> Lastly, only use Ethernet node if can't find phy node from ethernet-phy
> subnode and phy-handle.
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/net/phy/micrel_ksz90x1.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
> index e5f578201f35..e33789b7f747 100644
> --- a/drivers/net/phy/micrel_ksz90x1.c
> +++ b/drivers/net/phy/micrel_ksz90x1.c
> @@ -112,6 +112,7 @@ static int ksz90x1_of_config_group(struct phy_device *phydev,
>  {
>         struct udevice *dev = phydev->dev;
>         struct phy_driver *drv = phydev->drv;
> +       struct ofnode_phandle_args phandle;
>         int val[4];
>         int i, changed = 0, offset, max;
>         u16 regval = 0;
> @@ -128,8 +129,14 @@ static int ksz90x1_of_config_group(struct phy_device *phydev,
>         }
>
>         if (!ofnode_valid(node)) {
> -               /* No node found, look in the Ethernet node */
> -               node = dev_ofnode(dev);
> +               if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> +                                              &phandle)) {
> +                       /* No phy-handle found, look in the Ethernet node */
> +                       node = dev_ofnode(dev);
> +               } else {
> +                       /* phy-handle found */
> +                       node = phandle.node;
> +               }
>         }
>
>         for (i = 0; i < ofcfg->grpsz; i++) {
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index e5f578201f35..e33789b7f747 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -112,6 +112,7 @@  static int ksz90x1_of_config_group(struct phy_device *phydev,
 {
 	struct udevice *dev = phydev->dev;
 	struct phy_driver *drv = phydev->drv;
+	struct ofnode_phandle_args phandle;
 	int val[4];
 	int i, changed = 0, offset, max;
 	u16 regval = 0;
@@ -128,8 +129,14 @@  static int ksz90x1_of_config_group(struct phy_device *phydev,
 	}
 
 	if (!ofnode_valid(node)) {
-		/* No node found, look in the Ethernet node */
-		node = dev_ofnode(dev);
+		if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+					       &phandle)) {
+			/* No phy-handle found, look in the Ethernet node */
+			node = dev_ofnode(dev);
+		} else {
+			/* phy-handle found */
+			node = phandle.node;
+		}
 	}
 
 	for (i = 0; i < ofcfg->grpsz; i++) {