[U-Boot] [PATCH] eth: mtk-eth: fix incorrect read of phy-handle

In mt7629-rfb.dts, the phy-handle is a reference to the node phy0, not the node itself:
phy-handle = <&phy0>;
phy0: ethernet-phy@0 { reg = <0>; }
However the driver used ofnode_find_subnode("phy-handle") to read the node. It will always fail.
This patch replaces ofnode_find_subnode with dev_read_phandle_with_args to make sure the node can be read correctly.
Cc: Joe Hershberger joe.hershberger@ni.com Signed-off-by: Weijie Gao weijie.gao@mediatek.com --- drivers/net/mtk_eth.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index cc09404..0ef814c 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -1130,13 +1130,14 @@ static int mtk_eth_ofdata_to_platdata(struct udevice *dev) &priv->rst_gpio, GPIOD_IS_OUT); } } else { - subnode = ofnode_find_subnode(dev_ofnode(dev), "phy-handle"); - if (!ofnode_valid(subnode)) { + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, + 0, &args); + if (ret) { printf("error: phy-handle is not specified\n"); return ret; }
- priv->phy_addr = ofnode_read_s32_default(subnode, "reg", -1); + priv->phy_addr = ofnode_read_s32_default(args.node, "reg", -1); if (priv->phy_addr < 0) { printf("error: phy address is not specified\n"); return ret;

On Sun, Apr 28, 2019 at 2:09 AM Weijie Gao weijie.gao@mediatek.com wrote:
In mt7629-rfb.dts, the phy-handle is a reference to the node phy0, not the node itself:
phy-handle = <&phy0>; phy0: ethernet-phy@0 { reg = <0>; }
However the driver used ofnode_find_subnode("phy-handle") to read the node. It will always fail.
This patch replaces ofnode_find_subnode with dev_read_phandle_with_args to make sure the node can be read correctly.
Cc: Joe Hershberger joe.hershberger@ni.com Signed-off-by: Weijie Gao weijie.gao@mediatek.com
Acked-by: Joe Hershberger joe.hershberger@ni.com

Hi Weijie,
https://patchwork.ozlabs.org/patch/1092185/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks! -Joe
participants (2)
-
Joe Hershberger
-
Weijie Gao