Commit 3f1bb6ab authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller
Browse files

net: dsa: realtek-smi: fix OF child-node lookup

Use the new of_get_compatible_child() helper to look up child nodes to
avoid ever matching non-child nodes elsewhere in the tree.

Also fix up the related struct device_node leaks.

Fixes: d8652956 ("net: dsa: realtek-smi: Add Realtek SMI driver")
Cc: stable <>     # 4.19: 36156f92

Cc: Linus Walleij <>
Signed-off-by: default avatarJohan Hovold <>
Reviewed-by: default avatarAndrew Lunn <>
Signed-off-by: default avatarDavid S. Miller <>
parent cb12d72b
......@@ -347,16 +347,17 @@ int realtek_smi_setup_mdio(struct realtek_smi *smi)
struct device_node *mdio_np;
int ret;
mdio_np = of_find_compatible_node(smi->dev->of_node, NULL,
mdio_np = of_get_compatible_child(smi->dev->of_node, "realtek,smi-mdio");
if (!mdio_np) {
dev_err(smi->dev, "no MDIO bus node\n");
return -ENODEV;
smi->slave_mii_bus = devm_mdiobus_alloc(smi->dev);
if (!smi->slave_mii_bus)
return -ENOMEM;
if (!smi->slave_mii_bus) {
ret = -ENOMEM;
goto err_put_node;
smi->slave_mii_bus->priv = smi;
smi->slave_mii_bus->name = "SMI slave MII";
smi->slave_mii_bus->read = realtek_smi_mdio_read;
......@@ -371,10 +372,15 @@ int realtek_smi_setup_mdio(struct realtek_smi *smi)
if (ret) {
dev_err(smi->dev, "unable to register MDIO bus %s\n",
goto err_put_node;
return 0;
return ret;
static int realtek_smi_probe(struct platform_device *pdev)
......@@ -457,6 +463,8 @@ static int realtek_smi_remove(struct platform_device *pdev)
struct realtek_smi *smi = dev_get_drvdata(&pdev->dev);
if (smi->slave_mii_bus)
gpiod_set_value(smi->reset, 1);
return 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment